Friday, March 29
Shadow

How to upgrade the php version to php7.4 in VestaCP or Vesta on Ubuntu.

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 binds with 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 is the troubleshooting of Roundcube if there is any database-related issue after upgrading to php7.4.
Fix roundcube database-related issue

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

35 Comments

  • v live bts 22

    Its not my first time to pay a quick visit this
    web page, i am browsing this website dailly and get good
    information from here every day.

  • I absolutely love your blog.. Pleasant colors & theme. Did you make this website yourself?
    Please reply back as I’m trying to create my own personal website and want to find out where you got this from or what the theme
    is named. Many thanks!

  • While these tricks are easy to into your regular conversation routine, correctly practiced
    often. Bring the fear right down to the tiny thing
    around the globe. or, again, pick a different emotion altogether.

  • Josh

    Thanks for this great tutorial. I was able to successfully upgrade from php7.2 to php7.4.

    I have one question though, I’m hoping someone can help answer.

    After I installed php7.4 and enabled it on apache. “php -v” showed that I had php7.4 installed. However, after I run the command “apt remove php7.2*”, the installer will remove php7.2 and then automatically install php8.0. When I check with “php -v” after I run the apt remove command, it shows that php8.0 has been installed.

    Why does this happen and how to avoid it? And does it matter? It seems that since I did not enable it, php7.4 is still running and shows when I do a phpinfo(); command in a php file, but I’m just concerned that php8.0 has been installed and may break something else.

    Any help would be appreciated!

  • Very nice tutorial, everything worked great. I just want to include that there is spelling error in the command to restart apache. Thank you so much

  • A fascinating discussion is worth comment. I believe that you need to
    publish more about this subject, it might not be
    a taboo matter but typically folks don’t talk about such subjects.
    To the next! Kind regards!!

  • Greate pieces. Keep posting such kind of info on your page.
    Im really impressed by it.
    Hello there, You’ve done an excellent job. I’ll definitely digg it and
    for my part suggest to my friends. I’m confident they will be benefited
    from this website.

  • Have you ever thought about adding a little bit more than just your
    articles? I mean, what you say is fundamental and everything.
    But think of if you added some great pictures or videos to give your posts more, “pop”!

    Your content is excellent but with images and
    clips, this website could definitely be one of the very best in its
    niche. Awesome blog!

  • It’s a pity you don’t have a donate button!
    I’d without a doubt donate to this brilliant blog! I suppose for now i’ll settle for bookmarking and adding
    your RSS feed to my Google account. I look forward to brand new updates and will share this
    website with my Facebook group. Talk soon!

  • Wonderful goods from you, man. I’ve understand your stuff
    previous to and you’re just too great. I actually like what you have acquired here, really like what you’re stating and the way in which you say it.
    You make it entertaining and you still take care of to keep it sensible.
    I can not wait to read much more from you. This is actually a great web site.

  • What’s Going down i’m new to this, I stumbled upon this I have
    discovered It positively helpful and it has aided me out loads.
    I am hoping to contribute & help different customers like its
    helped me. Great job.

  • It’s remarkable to go to see this website and reading the views
    of all friends on the topic of this piece of writing, while I am also zealous of getting experience.

  • Have you ever considered about adding a little bit more than just your articles?
    I mean, what you say is important and all. Nevertheless imagine if you added some great images or videos to give your posts more, “pop”!
    Your content is excellent but with pics and video clips,
    this site could definitely be one of the greatest in its field.

    Very good blog!

Leave a Reply to joker 123 Cancel reply

Your email address will not be published. Required fields are marked *