PHP 8.3 brings performance improvements, typed class constants, the json_validate() function, and various engine enhancements over PHP 8.2. This guide installs PHP 8.3 on Ubuntu 24.04 LTS using the Ondrej PPA — the most up-to-date source for PHP on Ubuntu.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- A user with sudo privileges
Step 1 – Add the Ondrej PHP PPA
The Ondrej PPA provides the latest PHP releases for Ubuntu:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
Step 2 – Install PHP 8.3 CLI
Install the command-line PHP interpreter:
sudo apt install php8.3 php8.3-cli -y
Step 3 – Install Common PHP Extensions
Install extensions needed by most web applications:
sudo apt install php8.3-fpm php8.3-mysql php8.3-pgsql php8.3-mbstring php8.3-xml php8.3-curl php8.3-zip php8.3-gd php8.3-bcmath php8.3-opcache php8.3-intl php8.3-redis -y
Step 4 – Verify the Installation
Check the installed version:
php8.3 -v
List loaded modules:
php8.3 -m
Step 5 – Start and Enable PHP-FPM
Enable the PHP-FPM service for use with Nginx or Apache:
sudo systemctl start php8.3-fpm
sudo systemctl enable php8.3-fpm
sudo systemctl status php8.3-fpm
Step 6 – Configure PHP-FPM for Nginx
In your Nginx server block, add the PHP handler:
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
}
Step 7 – Tune php.ini for Production
Open the FPM php.ini:
sudo nano /etc/php/8.3/fpm/php.ini
Recommended production settings:
memory_limit = 256M
max_execution_time = 60
upload_max_filesize = 64M
post_max_size = 64M
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
Restart PHP-FPM:
sudo systemctl restart php8.3-fpm
Step 8 – Switch Default PHP Version
If multiple PHP versions are installed, switch the default:
sudo update-alternatives --set php /usr/bin/php8.3
Conclusion
PHP 8.3 is now installed on Ubuntu 24.04 LTS with FPM configured for use with Nginx. The OPcache extension provides a significant performance boost for PHP applications.