Upgrade your existing PHP Version to PHP 5.6 or PHP 7 on Ubuntu Server
Let’s see how to upgrade your existing PHP Version to PHP 5.6 or PHP 7 on Ubuntu Server.
Fist of all, check the current PHP version installed on your machine by using the following command:
$ php -v
If your server has PHP 5.5 installed on it and you want to upgrade to PHP 5.6, you will first have to remove PHP 5.5 from your server. You can use the following commands to remove it:
$ sudo apt remove --purge php* -y $ sudo apt autoremove -y
After removing PHP 5.5, you will be able to install PHP 5.6 on your server. You may use the following set of commands to do so:
$ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get -y update $ sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
After installing PHP 5.6 on your server successfully, you can again check its version by using the following command:
$ php -v
You can check the PHP version on the web browser also. In case the web browser is not showing the correct PHP version, you need to restart the Apache Server or Web Server whichever you are using. To restart Apache Server, you can use the following command:
$ sudo service apache2 restart
Similarly, for upgrading to PHP 7.x version you need to follow the same (as mentioned above) steps and you just need to replace PHP 5.6 to PHP 7.x in the installation commands.
That’s how you can upgrade the PHP version of your server (Ubuntu).
Like & Share this Article to help others as well.
Thank You!If you have any queries or doubts about this topic please feel free to contact us . We are here to help you!