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:
- Update the package list and install software-properties-common:
sudo apt update
sudo apt install software-properties-common
- Add the Ondrej PHP repository, which provides different PHP versions:
sudo add-apt-repository ppa:ondrej/php
- Update the package list again after adding the repository:
sudo apt update
- 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
- Once the installation is complete, you can check the installed PHP version:
php -v
- 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
- 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.
Leave a Reply
Want to join the discussion?Feel free to contribute!