Installing PHP 8.x on Ubuntu 22.04 Example




Installing PHP 8.x on Ubuntu 22.04 Example

Hi Guys,

In this tutorial, you will learn How to Install and Configure PHP 8.x on Ubuntu 22.04?. you can understand a concept of Ubuntu 22.04 on Install PHP 8.x. you will learn Step by Step Install PHP 8.x on Ubuntu 22.04. I explained simply step by step PHP 8.x to Install and Run on Ubuntu 20.04.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Use the following steps to install and configure PHP 8.x on ubuntu 22.04 system:

Step 1 – Update System Dependencies

Step 2 – Add PHP PPA

Step 3 – Install PHP 8.x for Apache

Step 4 – Install PHP 8.x Extensions

Step 5 – Verify PHP Version

Step 6 – Configure PHP 8.x

Step 1: Update System Dependencies

Run the following command at a command prompt to update the latest packages or dependencies:

sudo apt update

sudo apt upgrade

Step 2: Add PHP PPA

Using following command to install PHP 8.1

sudo apt install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt update

Step 3: Install PHP 8.x for Apache

Execute the following command on command prompt to install PHP 8.1:

sudo apt install php8.1

You can confirm the installation using the following command:

php -v

Step 4: Install PHP 8.x Extensions

Using the following command, we can install PHP extensions:

sudo apt install php8.1-extension_name

Now, install some commonly used php-extensions with the following command.

sudo apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-redis php8.1-intl -y

Step 5: Verify PHP Version

Using the following command, we can easily verify PHP version:

php -v


PHP 8.1.5 (cli) (built: Apr 21 2022 10:32:13) (NTS)

Copyright (c) The PHP Group

Zend Engine v4.1.5, Copyright (c) Zend Technologies

with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies

Step 6: Configure PHP 8.x

Execute the following command on command prompt to edit php.ini:

sudo nano /etc/php/8.1/apache2/php.ini

Hit F6 for search inside the editor and update the following values for better performance.

upload_max_filesize = 32M

post_max_size = 48M

memory_limit = 256M

max_execution_time = 600

max_input_vars = 3000

max_input_time = 1000

Then execute the following command on command prompt to restart apache web server:

sudo service apache2 restart