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, double-check which PHP version your server is running:

php -v

Add the repos for this installation:

add-apt-repository ppa:ondrej/php
add-apt-repository ppa:ondrej/apache2

Next, we will install PHP 7.4 with the following command:

apt install php7.4

Next, we will install the needed packages to run alongside 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:

a2dismod php7.2

Then we will enable the Php7.4 version:

a2enmod php7.4

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, on your website. Navigate to your public_html folder and use nano info.php, and in that file, type:


Now navigate to your domain name with your address of the php.php file, and you should see you are currently running PHP 7.4. If you are happy to run only PHP 7.4, you are finished with this tutorial. However, if you want to have PHP 8.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 PHP 8.0. Let’s start by installing PHP 8.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 installation of PHP 8.0 is complete. Now should you want to use PHP 8.0 instead of PHP 7.4, you will need to disable PHP 7.4 and enable PHP 8.0 and then restart apache2:

a2dismod php7.4
a2enmod php8.0
systemctl restart apache2

I will conclude that PHP 8.0 may not require to be enabled with the

a2enmod php8.0 

Command as a result, it may be expected that you will receive an error while executing it. Should such an error happen, you can safely ignore it and you may now use PHP 8.0.

Please also remember that your website contains the info.php file we created earlier with Nano. You will want to remove it by navigating to that directory and deleting the file with the following: 

rm info.php -f


Please let me know if you run into any problems or if this process no longer works on newer upgrades.