In this blog, I will show you how you can update VestaCP Php version 7.2 to Php 7.4 and Php version 8.0 on Linux Ubuntu 18.04.
First add the repos for this installation :
Next we will install php7.4 with the following command :
apt install php7.4
Next we will install the needed packages to run along side php7.4 :
apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl
Next, we will need to disable the current version of VestaCP Php7.2 by executing the following command :
Then we will enable the Php7.4 version :
Then you need to restart apache2 :
systemctl restart apache2
Now that we have disabled the old version, and enabled the new version, we need to remove the old version :
apt remove php7.2* apt autoremove
There are two additional extensions we will install which are commonly used on some websites and cloud technology servers. They are gmp, and bcmath. The following command will enable these :
apt install php7.4-bcmath php7.4-gmp
Next restart apache2 once again.
systemctl restart apache2
Next, in your website. Navigate to your public_html folder and use nano php.php and in that file, type :
<?php phpinfo(); ?>
Now navigate to your domain name with your address of the php.php file and you should see you are now running Php7.4. If you are happy to run only Php7.4, you are finished with this tutorial. However, if you want to have Php8.0, you may want to continue with the remainder of this tutorial.
Next we will install php 8.0 but we won’t be enabling it because not all websites and content management systems support the latest version of Php8.0. Lets start by installing Php8.0 :
apt install php8.0 apt install php8.0-common php8.0-mysql php8.0-xml php8.0-curl php8.0-gd php8.0-imagick php8.0-cli php8.0-dev php8.0-imap php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip php8.0-intl
Notice, that the install of Php8.0 is complete. Now should you want to use php8.0 instead of Php7.4, you will need to disable Php7.4 and enable Php8.0 and then restart apache2 :
a2dismod php7.4 a2enmod php8.0 systemctl restart apache2
I will conclude that Php8.0 may not need to be enabled with the :
a2enmod php8.0 command as as a result, it may be normal that you receive an error while executing it. Should such an error happen, you can safely ignore it and you may now use Php8.0.
Please also remember that your website contains the php.php file we created earlier with Nano. You will want to remove it by navigating to that directory and deleting the file with
rm php.php -f.