Logo

How to Install PHP 8.2 on Ubuntu 23.04

Dec 02, 2023

To install PHP 8.2 on Ubuntu 23.04, follow the steps below.

Step 1 : Update

sudo apt update

Step 2 : Since ppa:ondrej/php does not officially support non-LTS versions of Ubuntu, follow these steps:

- Add the Repository (ppa:ondrej/php)

sudo add-apt-repository ppa:ondrej/php

- Open the file:

sudo nano /etc/apt/sources.list.d/ondrej-ubuntu-php-lunar.list

- Find "lunar" and replace it with "jammy".

- Make the necessary change and save the file.

Step 3 : Create the file /etc/apt/preferences.d/ondrejphp and add the following code:

sudo nano /etc/apt/preferences.d/ondrejphp

Add the following content:

Package: libgd3
Pin: release n=lunar
Pin-Priority: 900

Save the file.

Step 4 : Update again.

sudo apt update

Step 5 : Install PHP 8.0 core (php8.0 php8.0-cli php8.0-fpm)

sudo apt install php8.2 php8.2-cli php8.2-fpm

Step 6 : Install commonly used extensions:

sudo apt install php8.2-{mysql,curl,xsl,gd,common,xml,zip,xsl,soap,bcmath,mbstring,gettext,imagick}

Explanation:

- mysql: MySQL database support.

- curl: Client URL library for making requests.

- xsl: XSLT processing.

- gd: Image manipulation library.

- common: Common files for PHP.

- xml: XML parsing support.

- zip: ZIP archive support.

- soap: SOAP support.

- bcmath: Arbitrary precision mathematics.

- mbstring: Multibyte string support.

- gettext: Gettext support for internationalization.

- imagick: ImageMagick PHP extension for image processing.

Step 7 : Check PHP Version

php -v

Congratulations, you have successfully installed PHP 8.2 on Ubuntu 23.04 with commonly used extensions.

Recommended