Logo

How to Install PHP 8.0 on Ubuntu 23.04

Dec 02, 2023

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

Step 1 : Ensure your system is up-to-date by running the following command:

sudo apt update

Step 2 : Add the Repository

Since ppa:ondrej/php does not officially support non-LTS versions, you need to make a small modification.

- Add the repository:

sudo add-apt-repository ppa:ondrej/php

- Open the repository file:

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

- Find "lunar" and replace it with "jammy". Save the changes.

Step 3 : Update

Update the package list again:

sudo apt update

Step 4 : Create Pinning Preferences

Create a preferences file:

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

Add the following code to prioritize the correct package version:

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

Step 5 : Install PHP 8.0 core packages:

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

Step 6 : Install frequently used PHP extensions along with brief explanations:

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

- mysql: MySQL database support

- curl: cURL library for making HTTP requests

- xsl: XSL module for XML manipulation

- gd: GD Graphics Library for image processing

- common: Common functions and classes

- xml: XML support

- zip: Zip archive support

- soap: SOAP protocol support

- bcmath: Arbitrary precision mathematics

- mbstring: Multibyte string support

- gettext: Gettext module for multi-language support

- imagick: ImageMagick PHP extension for image processing

Step 7 : Check PHP Version

Verify the PHP version installed:

php -v

Congratulations! You have successfully installed PHP 8.0 on Ubuntu 23.04 with necessary extensions. Happy coding!

Recommended