VestaCP or vesta is the most recommended, free, and open-source hosting application. Till this post, it uses a 7.2 version of PHP. In this post, I will install or upgrade php7.4 in vesta.
First, let’s check the current PHP version.

# php -v

The output of the command will be looks like this.

PHP 7.2 on vesta

The second method to verify the PHP version is, create a phpinfo.php file in the root directory and add this line without quote “<?php phpinfo(); ?>“. Restart the apache2 service and refresh or browse the web page. Your URL will be http://example.com or IP_address/pfpinfo.php

PHP version check vesta GUI

We have tested and verified the PHP version. The current version is 7.2
Let’s install and configure the php7.4 on the vesta.
Install software common properties and PHP pap repository.

# apt install software-common-properties
# add-apt-repository ppa:ondrej/php

After installing the software common properties and php ppa repository. Install the php7.4 and common extensions.

# apt install 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

PHP 7.4 is installed successfully. Let’s check again the PHP version from both methods. Running PHP -v command and refreshing or browsing the website. php -v command shows that the PHP version is upgraded to the 7.4 but the website or vesta does not acknowledge the up-gradation of PHP. It is still using php7.2.
Because of apache still bind to the php7.2. To fix this issue, we need to disable php7.2 and enable php7.4 with apache2. And restart the apache2 service.

# a2dismod php7.2
# a2enmod php7.4
# systemctl restart apache2

Now Apache2 bind with the php7.4 and vesta also working fine with it.

php7.4 gui vesta

Yes, we successfully upgrade to the php7.4. Now we can remove the php7.2 from the system and make sure that everything is working fine.

# apt remove php7.2*
# apt autoremove

Reboot your system. Everything should be fine now.
If you missed some common extensions of php7.4, the issue will be unable to access PHPMyAdmin and Roundcube email. Install those extensions and reboot the whole vesta system, or restart the php-fpm, Apache2, and vesta service. The link below it the troubleshooting of Roundcube if there is any database-related issue after upgrading to the php7.4.
Fix roundcube database-related issue

If you have any question regarding this topic, please leave the comment below.

Leave a Reply