Page 1 of 1

[Vesta Install] Force Specific PHP Version as default (Ubuntu/Debian)

Posted: Wed May 27, 2020 9:21 pm
by codejp3
I've never liked the limitations of PHP versions that seems to be inherent with VestaCP. The CentOS folks get the Remi repo to help remedy that, but there's no love for us Ubuntu/Debian users. There are several (outdated) tutorials for how to add PHP versions AFTER Vesta has been installed, but they're awkward and don't integrate with Vesta very well.

This "patch" will install the PHP version of YOUR CHOICE as the default, and integrate it with Vesta core as the default.


1.) Start with a fresh VPS/Server with the OS Installed (we're stuck at Ubuntu 18.04/Debian 9 for now until Vesta updates their repo to support newer versions).


2.) Make sure it's up-to-date

Code: Select all

sudo apt update && sudo apt dist-upgrade

3.) Use the Sury PPA to add newer versions of PHP

Code: Select all

sudo add-apt-repository ppa:ondrej/php
or if you don't have add-apt-repository available:

Code: Select all

sudo apt -y install lsb-release apt-transport-https ca-certificates wget && sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

4.) Do another update/upgrade

Code: Select all

sudo apt update && sudo apt dist-upgrade

5.) Download the vst-install-[OS] script

Code: Select all

sudo cd /tmp; sudo wget http://vestacp.com/pub/vst-install-ubuntu.sh
*Note: change "ubuntu" to "debian" if you're using debian


6.) Replace the occurrences of "php-[SOMETHING]" with "php[VERSION]-[SOMETHING]"

Code: Select all

ver=7.4; sudo sed -i "s/php-cgi/php$ver-cgi/g; s/php-common/php$ver-common/g; s/php-curl/php$ver-curl/g; s/php-fpm/php$ver-fpm/g; s/php-mysql/php$ver-mysql/g; s/php-pgsql/php$ver-pgsql/g" /tmp/vst-install-ubuntu.sh 
*Note: change "7.4" to the version YOU want.


7.) Make the script executable

Code: Select all

sudo chmod +x /tmp/vst-install-ubuntu.sh
*Note: change "ubuntu" to "debian" if you're using debian


8.) Install VestaCP

Code: Select all

sudo bash vst-install-ubuntu.sh --nginx yes --phpfpm yes --apache no --named yes --remi no --vsftpd no --proftpd yes --iptables yes --fail2ban yes --quota yes --exim yes --dovecot yes --spamassassin yes --clamav no --softaculous no --mysql yes --postgresql yes
*Note: change "ubuntu" to "debian" if you're using debian
*Note2: change any options for your installation. You will be prompted for the domain/username/password. You may also have to add "--force" at the end if you run into install issues.


This will install VestaCP with the PHP version as default that YOU want. Something that, in my opinion, should be an installation option in the first place. There may actually be a legitimate reason Vesta has chosen not to allow for any PHP version options at install time, but I haven't found any yet.


This is a very crude but effective way to accomplish the task. I've considered altering the installer AND Vesta core to allow you to choose any version(s) you want, for any domain, at any time. I can't justify spending the time doing so right now, but if there is enough interest, then perhaps I will.

Let me know if you run into issues or have questions.