Overview
By default, Ubuntu 18.04 LTS includes PHP 7.2 in its official repositories. However, many modern applications require PHP 7.3 or later—for example, the latest WordPress versions, Laravel frameworks, and other web applications.
This guide shows how to install PHP 7.3 on Ubuntu 18.04 using Ondřej Surý’s PPA, a widely-trusted source for newer PHP versions.
Note
Why Not Use Official Repos? Ubuntu LTS versions (like 18.04) maintain package versions for stability. Third-party PPAs like Ondřej’s provide newer versions with security updates for the application lifecycle.
Prerequisites
- Ubuntu 18.04 LTS or derivative (Linux Mint, Pop!_OS, etc.)
- Root or sudo access
- Internet connection
- apt package manager
Step 1: Add Ondřej Surý’s PPA Repository
Ondřej Surý maintains a well-maintained repository of unsupported PHP versions for Debian and Ubuntu. First, add his PPA:
sudo add-apt-repository ppa:ondrej/phpsudo apt updateThis adds the PPA to your system and refreshes the package list.
Tip
Adding multiple repos: You can add other PPAs from Ondřej for related tools like ppa:ondrej/apache2 (for Apache) or ppa:ondrej/nginx (for Nginx) if needed.
Step 2: Install PHP 7.3
After adding the PPA, install PHP 7.3. Choose based on your web server:
For Nginx (with PHP-FPM)
sudo apt install php7.3-fpmThis installs PHP 7.3 FastCGI Process Manager (FPM) for use with Nginx. FPM is more efficient than mod_php for high-traffic sites.
For Apache (with mod_php)
sudo apt install php7.3This installs PHP 7.3 with Apache module support, automatically enabling mod_php.
Install Common Extensions (Optional)
Most applications need additional PHP extensions:
sudo apt install php7.3-mysql php7.3-gd php7.3-curl php7.3-mbstring php7.3-xml php7.3-zipNote
Common Extensions Explained:
php7.3-mysql— MySQL/MariaDB database supportphp7.3-gd— Image manipulation (required for many CMS platforms)php7.3-curl— HTTP requests (needed for API calls)php7.3-mbstring— Multi-byte string support (internationalization)php7.3-xml— XML parsing supportphp7.3-zip— ZIP archive support
Step 3: Verify the Installation
Confirm that PHP 7.3 was installed correctly:
php -vOutput should show:
PHP 7.3.x-x (cli) (built: ...)Copyright (c) 1997-2019 The PHP GroupCheck PHP Information
For detailed information about your PHP installation (modules, configuration, etc.):
php -iOr create a simple info script:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.phpThen visit http://yourserver/info.php in a browser.
Warning
Security: Always delete the info.php file after verification. Exposing phpinfo() publicly reveals system details to attackers.
Step 4: Enable PHP-FPM Service (Nginx only)
If you installed php7.3-fpm, enable and start the service:
sudo systemctl enable php7.3-fpmsudo systemctl start php7.3-fpmVerify it’s running:
sudo systemctl status php7.3-fpmTroubleshooting
Dependency Conflicts
If you receive dependency errors, clear the package cache:
sudo apt cleansudo apt autocleansudo apt autoremovesudo apt updateMultiple PHP Versions
If you have multiple PHP versions installed, check which is default:
update-alternatives --list phpSwitch versions:
sudo update-alternatives --set php /usr/bin/php7.3Check Apache Module
For Apache, verify mod_php is enabled:
sudo a2enmod php7.3sudo systemctl restart apache2Summary
You have successfully installed PHP 7.3 on Ubuntu 18.04. Your web server (Nginx or Apache) can now run modern PHP applications that require version 7.3. Remember to keep your system updated with:
sudo apt update && sudo apt upgradeFor additional help, consult the official Ondřej Surý PPA page or PHP documentation.