How to install PHP 7.3 on Ubuntu 20.04

To install PHP 7.3 on Ubuntu 20.04, you’ll need to use a third-party repository since PHP 7.3 is not available in the default Ubuntu repositories. Here are the steps to install PHP 7.3:

  1. Update the package list and install software-properties-common:
sudo apt update
sudo apt install software-properties-common
  1. Add the Ondrej PHP repository, which provides different PHP versions:
sudo add-apt-repository ppa:ondrej/php
  1. Update the package list again after adding the repository:
sudo apt update
  1. Install PHP 7.3 and the necessary modules:
sudo apt install php7.3
sudo apt install php7.3-cli php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-xml php7.3-zip
  1. Once the installation is complete, you can check the installed PHP version:
php -v
  1. If you have other PHP versions installed, you can switch between them using the update-alternatives command. For example, to switch to PHP 7.3:
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set phar /usr/bin/phar7.3
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.3
  1. Restart the PHP-FPM service to apply changes (if you installed php7.3-fpm):
sudo systemctl restart php7.3-fpm

That’s it! You now have PHP 7.3 installed on your Ubuntu 20.04 system.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply