How to install PHP and upgrade it ?
Introduction
PHP is a widely-used scripting language particularly suited for web development. It can be embedded into HTML and is often used in conjunction with web servers like Apache. This guide will walk you through the installation of PHP 7.2 along with the Apache PHP module and PHP FPM, and how to upgrade PHP from version 7.2 to 7.3 on an Ubuntu system.
Prerequisites
Before proceeding, ensure you have the following:
1. An Ubuntu system with administrative (sudo) access.
2. An active internet connection for downloading packages.
3. Basic knowledge of using the terminal.
Installing PHP 7.2 with Apache
1. Install PHP and Apache PHP Module
sudo apt install php libapache2-mod-php
2. Restart Apache Service
sudo systemctl restart apache2
Installing PHP 7.2 FPM
1. Install PHP FPM Package
sudo apt install php-fpm
2. Check PHP FPM Service Status
systemctl status php7.2-fpm
3. Check PHP Version
php -v
Upgrading PHP from 7.2 to 7.3
1. Install Software Properties Common
sudo apt-get install software-properties-common
2. Add PHP PPA Repository
sudo add-apt-repository ppa:ondrej/php
3. Update Package List
sudo apt-get update
4. Upgrade Installed Packages
sudo apt-get upgrade
5. Install PHP 7.3
sudo apt-get install -y php7.3
6. Check PHP Version
php -v
Conclusion
By following these steps, you can successfully install PHP 7.2 along with the necessary modules and upgrade your PHP version to 7.3 on an Ubuntu system. Ensuring your PHP version is up-to-date is crucial for maintaining security and leveraging the latest features and improvements. Always verify the version after installation or upgrade to confirm the changes have been applied correctly.