Knowledgebase

How to Switch PHP Versions (cPanel MultiPHP and Ubuntu VPS)

To switch PHP versions on cPanel shared hosting, open cPanel → Software → MultiPHP Manager, tick the domain, choose the new version and click Apply. If your account shows Select PHP Version instead, use CloudLinux PHP Selector. On an Ubuntu VPS, install the new version's PHP-FPM package (from the ondrej/php PPA if Ubuntu doesn't ship it), point Nginx or Apache to that version's FPM socket, and restart the services. This guide covers both setups, plus raising PHP limits and confirming which version is active.

Prerequisites

  • For shared hosting: a cPanel login for a Cloudesta shared hosting account.
  • For a VPS: root or sudo SSH access to an Ubuntu 24.04 or 22.04 server running Nginx or Apache.
  • A recent backup of your site files and database. JetBackup is available in cPanel. On a VPS, use your own backups.
  • Your application's supported PHP versions. Check the WordPress, Laravel or plugin documentation.

1. How do I change the PHP version in cPanel?

MultiPHP Manager lets you set a different PHP version for each domain:

  • Log in to cPanel and go to Software → MultiPHP Manager.
  • Tick the checkbox next to the domain or subdomain you want to change.
  • Pick the version, for example PHP 8.3 (ea-php83), from the PHP Version drop-down at the top right.
  • Click Apply. The change takes effect within a few seconds.

A domain marked inherit uses the server's default version. Every domain keeps its own setting, so you can test a new version on a staging subdomain before switching the main site.

What if I see "Select PHP Version" instead?

On CloudLinux servers, cPanel may show Software → Select PHP Version (CloudLinux PHP Selector). To use it:

  • Choose a version from the drop-down at the top and click Set as current.
  • Open the Extensions tab and tick the modules your application needs, such as mysqli, pdo_mysql, intl, imagick or zip.
  • Use the Options tab to change values like memory_limit and upload_max_filesize.
PHP Selector only applies to domains using the server's default version in MultiPHP Manager (usually shown as inherit). If a domain is pinned to a specific ea-php version there, Selector changes will not affect it. Use one tool per domain, not both.

2. How do I increase memory_limit or upload_max_filesize in cPanel?

  • Go to Software → MultiPHP INI Editor.
  • On the Basic Mode tab, select the domain under Configure PHP INI basic settings.
  • Set the values you need, then click Apply. Typical values are memory_limit 256M, upload_max_filesize 64M, post_max_size 64M (equal to or larger than the upload size) and max_execution_time 120.

The Editor Mode tab lets you edit the domain's php.ini directly. Values are still capped by your plan's resource limits. If a site needs more, open a ticket to discuss a plan upgrade.

3. How do I check which PHP version my site is using?

In File Manager, create a file named info.php in the domain's document root (usually public_html) with this content:

<?php phpinfo();

Visit https://example.com/info.php. The header shows the PHP version, and the table lists the loaded php.ini, the limits and the enabled extensions. Delete the file as soon as you are done, because it exposes server details.

4. How do I install another PHP version on an Ubuntu VPS?

Ubuntu 24.04 ships PHP 8.3 and Ubuntu 22.04 ships PHP 8.1. For other versions, add Ondřej Surý's PPA. It is the widely used third-party source for multiple PHP versions on Ubuntu.

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update

Install FPM and the common extensions for the version you want. The example uses 8.3; replace it with 8.2, 8.4 and so on as needed:

sudo apt install -y php8.3-fpm php8.3-cli php8.3-mysql php8.3-curl \
  php8.3-mbstring php8.3-xml php8.3-zip php8.3-gd php8.3-intl php8.3-bcmath
Install php8.3-fpm rather than the bare php8.3 package. The bare package can pull in libapache2-mod-php8.3 and Apache, even on an Nginx server.

Each version runs as its own service with its own socket and config, so older versions stay installed alongside the new one:

ls /run/php/
sudo systemctl enable --now php8.3-fpm

Settings are not copied between versions. To change web PHP limits, edit /etc/php/8.3/fpm/php.ini. Command-line PHP reads /etc/php/8.3/cli/php.ini instead.

5. How do I change the default PHP CLI version?

sudo update-alternatives --config php
# or set it directly:
sudo update-alternatives --set php /usr/bin/php8.3
php -v

This affects Composer, cron jobs and Artisan commands that call php. It does not change the web server's PHP version.

6. How do I point Nginx or Apache to the new PHP-FPM socket?

Nginx

Open your site's config, for example /etc/nginx/sites-available/example.com, and update fastcgi_pass:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
sudo nginx -t && sudo systemctl reload nginx

Apache

To switch the whole server, enable the FPM proxy modules, enable the new version's config and disable the old one. Replace 8.1 with whatever you ran before:

sudo a2enmod proxy_fcgi setenvif
sudo a2disconf php8.1-fpm
sudo a2enconf php8.3-fpm
# only if mod_php was in use:
sudo a2dismod php8.1
sudo apachectl configtest && sudo systemctl restart apache2

To set PHP per site instead, add this inside the site's <VirtualHost> block:

<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost"
</FilesMatch>

After any php.ini change, restart FPM with sudo systemctl restart php8.3-fpm. Once everything works, you can stop the old version with sudo systemctl disable --now php8.1-fpm.

Verify it works

  • Load a temporary info.php and confirm the version. On a VPS, Server API should read FPM/FastCGI. Delete the file afterwards.
  • Run php -v and php -m on the VPS to check the CLI version and modules.
  • Run systemctl status php8.3-fpm and confirm it shows active (running).
  • Browse your site, log in to the admin area, and test forms and uploads.

Common problems

The site shows errors or a blank page after switching. The code or plugins use functions removed in the new version. Switch back to the previous version so the site is online again. Then read error_log in the site folder (or /var/log/nginx/error.log or /var/log/apache2/error.log), update the CMS, theme and plugins, and switch again.

"Call to undefined function mysqli_connect()" or a similar missing-extension error. Each version has its own extensions. On CloudLinux, tick the extension in Select PHP Version → Extensions. On a VPS, install it for that exact version (for example sudo apt install php8.3-mysql) and restart php8.3-fpm.

The cPanel version doesn't change, or PHP files download instead of running. An old handler in .htaccess is overriding MultiPHP. Look for AddHandler application/x-httpd-ea-php74 or a block marked php -- BEGIN cPanel-generated handler. Remove it (keep a copy first), then re-apply the version in MultiPHP Manager.

Nginx shows 502 Bad Gateway. The socket in fastcgi_pass doesn't exist or FPM isn't running. Compare the path with ls /run/php/ and start the service with sudo systemctl start php8.3-fpm.

Uploads still fail after raising upload_max_filesize. Make sure post_max_size is at least as large. On Nginx, also set client_max_body_size 64M; and reload Nginx.

Frequently asked questions

Can different sites use different PHP versions?

Yes. In cPanel, MultiPHP Manager sets the version per domain. On a Cloud VPS, give each site's Nginx or Apache config its own FPM socket.

How do I run cron jobs with a specific PHP version on cPanel?

Use the full binary path in the cron command, for example /opt/cpanel/ea-php83/root/usr/bin/php. On CloudLinux PHP Selector setups, use /opt/alt/php83/usr/bin/php.

Will switching PHP versions delete my files or database?

No. Only the PHP interpreter changes, and you can switch back at any time. Taking a backup first is still recommended.

Need help? If your site still fails after switching, or you need higher limits than your plan allows, open a support ticket with the domain name and the exact error message.

Was this answer helpful?

0 Users Found This Useful

Powered by WHMCompleteSolution