In this tutorial, I am going to explain how you can install PHP 8.3 on Ubuntu 22.04. PHP(Hypertext Preprocessor) is the most popular server-side markup language. PHP is the most frequently updated programming language. If you execute the command to install PHP, it may not install the required PHP version. Sometimes we may need to install specific PHP versions, to smoothly run any script or framework.
Step 1: Update Ubuntu Repository
Before installation, update your package manager with the latest release packages from the Ubuntu repository. To update your Ubuntu packages, run the following command.
sudo apt update
sudo apt upgrade
(If you using root access, then you don’t need to add ‘sudo’ before the commands)
Step 2: Add PHP repository to Ubuntu’s repository
By default, PHP 8.3 package files are not available in Ubuntu’s repository. So we need to add Ondrej Sury PPA (PHP all versions packages) into the system. Run the following command first.
sudo apt install ca-certificates apt-transport-https software-properties-common
Once all the packages are installed, add the PPA using the following command.
sudo add-apt-repository ppa:ondrej/php
On successful addition of PPA, again update the repository by following command
sudo apt update
Step 3: Install PHP 8.3 on Ubuntu 22.04
Now, run the following command to install PHP 8.3 on the Ubuntu system.
sudo apt install php8.3
When you run this command, it will first ask you for permission. Enter ‘Y’ to continue the installation. Once installation is completed, you can check the PHP version by running the following command.
php -v
The output should look like
PHP 8.3.3-1+ubuntu22.04.1+deb.sury.org+1 (cli) (built: Feb 15 2024 18:38:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.3, Copyright (c) Zend Technologies
with Zend OPcache v8.3.3-1+ubuntu22.04.1+deb.sury.org+1, Copyright (c), by Zend Technologies
..................
..................
Congratulations, you have successfully installed PHP 8.3 on Ubuntu 22.04 LTS.
PHP Extensions installation on Ubuntu 22.04
If you are going to install WordPress or any other frameworks on Ubuntu 22.04, you will need to enable some of the PHP extensions. Let’s have a look at some of the important PHP extensions that are always required.
To install PHP extensions run the following commands
sudo apt install php8.3-mysql php8.3-imap php8.3-ldap php8.3-xml php8.3-curl php8.3-mbstring php8.3-zip
Install Apache Module for PHP 8.3
To install PHP as an Apache module, run the following command
sudo apt install libapache2-mod-php8.3
Install PHP FPM
To install the PHP FPM service, you need to use the following command.
sudo apt install php8.3-fpm
Once installation is completed, you can check the PHP FPM status by running the following command
sudo systemctl status php8.3-fpm
Output should be
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.3-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-02-19 15:28:29 IST; 51s ago
Docs: man:php-fpm8.3(8)
Process: 286621 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.3/fpm/pool.d/www.conf 83 (code=exi>
Main PID: 286617 (php-fpm8.3)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 9271)
Memory: 9.8M
CPU: 68ms
CGroup: /system.slice/php8.3-fpm.service
Check installed PHP Modules on Ubuntu 22.04
You can check all the available modules on your server by the below command.
php8.3 -m
Output will be
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
imap
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
Video Tutorial
Conclusion
In this tutorial, you have learned how to install PHP 8.3 on Ubuntu 22.04. If you have any doubts or do not understand the tutorial, you can always comment here. Also, refer to the official documentation for more details.