Installing a newer PHP version on VestaCP Print

  • vestacp, php, php-fpm, remi
  • 114

VestaCP does not provide a way to install or switch PHP versions from the panel, so a newer PHP has to be installed on the system and the panel pointed at it. This guide describes that procedure in a version-independent way — substitute the PHP version you actually want throughout.

Read this before you start.

These changes are not supported by the panel's developers, and they involve replacing the PHP that the panel itself relies on. Two consequences follow: the web server can break in ways that are not obvious, and automatic updates of the panel will no longer work afterwards.

Take a snapshot or a full backup first — see Backups and snapshots for CloudVM virtual servers — and, if the server matters, try the procedure on a test server with the same versions before touching production.

Check what you have now

php -v

Note the version and, if you are unsure of the stack, whether the site is served by Apache or by Nginx with PHP-FPM. The steps below assume PHP-FPM.

1. Stop the services

systemctl stop nginx
systemctl stop php-fpm

2. Add a repository with current PHP versions

The distribution's own repositories carry only one PHP version, which is why an external repository is needed.

RHEL-based systems (AlmaLinux, Rocky Linux, CentOS) — the Remi repository. Install the release package matching your major version, for example for EL9:

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

Debian and Ubuntu — the packages maintained by Ondřej Surý at packages.sury.org. Follow the instructions on that site for your release, then install php8.3-fpm and the extensions you need, and skip to step 5.

3. Install the new PHP version

On RHEL-based systems, with the version in both the repository name and the package prefix. For PHP 8.3:

dnf --enablerepo=remi-php83 install php83-php php83-php-fpm php83-php-cli \
  php83-php-common php83-php-mysqlnd php83-php-gd php83-php-mbstring \
  php83-php-xml php83-php-opcache php83-php-intl php83-php-pdo \
  php83-php-bcmath php83-php-process php83-php-pecl-imagick

Add or remove extensions according to what your applications need. A missing extension usually announces itself immediately as a CMS error.

4. Point the system at the new version

rm -f /usr/bin/php
ln -s /usr/bin/php83 /usr/bin/php

Remi keeps the PHP-FPM pool configuration under /etc/opt/remi/php83/php-fpm.d, while VestaCP generates its pool files in /etc/php-fpm.d. Link the two so that the panel's generated configuration is used:

ln -s /etc/php-fpm.d /etc/opt/remi/php83/php-fpm.d

5. Tell VestaCP which backend to use

In /usr/local/vesta/conf/vesta.conf, set:

WEB_BACKEND='php83-php-fpm'

Then rename the template directories so that they match the new backend name:

cd /usr/local/vesta/data/templates/web
mv php-fpm php83-php-fpm
cd /usr/local/vesta/data/templates/web/nginx
mv php-fpm php83-php-fpm

6. Start the services

systemctl start php83-php-fpm
systemctl enable php83-php-fpm
systemctl start nginx

7. Verify

Check the command-line version with php -v, and the version actually serving your sites by creating a temporary file containing <?php phpinfo(); in the site root. Delete that file afterwards — it discloses a great deal about the server.

Then open your sites and check that they work, including the parts that use the database and file uploads.

The alternative approach

Instead of changing the panel's configuration, you can name the new service php-fpm at system level so that VestaCP finds it where it expects to. That leaves the panel updatable but stops PHP-FPM from being updated automatically. The procedure above makes the opposite trade-off: PHP stays updatable, the panel does not.

Neither is ideal. If you regularly need current PHP versions, a panel that supports multiple versions natively — such as Plesk or ISPmanager — removes the problem entirely rather than working around it.

If something breaks

Restore the snapshot you took at the start; that is faster and more reliable than unpicking a partial change. If you cannot, open a ticket from your client area describing which step you reached and what the error was.


Was this answer helpful?

« Back