A WordPress update, a new Laravel deployment, or an aging PHP extension can quickly expose a version mismatch. Knowing how to set PHP versions correctly lets you keep each website compatible without changing a working application just to satisfy another one. The right method depends on whether your site runs on managed cPanel hosting or a VPS where you control the web server and PHP-FPM services.

Check what needs to change before switching PHP

PHP versions can be set at several levels: for an individual domain, for a hosting account, for the server's web-facing PHP handler, or for the command-line interface. These are not always the same. A server may run PHP 8.3 for a website through PHP-FPM while the `php -v` command still reports PHP 8.2 for scheduled tasks and deployment scripts.

Start by checking your application's supported PHP range. WordPress, WooCommerce, Drupal, Magento, Laravel, and older custom applications may have different requirements. A newer PHP release usually improves performance and security, but an unsupported theme, plugin, encoded file, or legacy library can cause errors after the change.

Before switching, take a current backup of website files and the database. If the site processes orders, collects form submissions, or runs background jobs, schedule the change during a quieter period. For business-critical applications, test the new version on a staging copy first.

Also record the PHP extensions your application uses. Common examples include `curl`, `mbstring`, `mysqli`, `pdo_mysql`, `xml`, `zip`, `gd`, `intl`, and `opcache`. Installing or selecting a PHP version without its required extensions is one of the most common reasons a site returns a 500 error after an upgrade.

How to set PHP versions in cPanel

For shared hosting and reseller accounts, cPanel is normally the safest place to manage PHP. The exact menu name depends on the server configuration, but most cPanel environments use either MultiPHP Manager, Select PHP Version, or both.

Set a version for one domain with MultiPHP Manager

Log in to cPanel and open MultiPHP Manager. Select the domain or subdomain you want to change, choose the required PHP version from the dropdown menu, and apply the setting. This approach is useful when one account hosts several sites with different compatibility requirements.

For example, a current WordPress site may use PHP 8.3 while an older client site remains on an earlier supported release until its plugins are updated. Setting PHP per domain prevents one application from forcing a server-wide compromise for every other site in the account.

After changing the version, load the site's home page, login area, contact forms, and any checkout or customer portal pages. Do not treat a successful homepage load as a complete test. Many PHP compatibility problems appear only in admin screens, cron jobs, payment integrations, or image-processing functions.

Select extensions and PHP options when available

Some cPanel installations provide a Select PHP Version tool. Use it to choose the PHP release and enable extensions required by the application. The same area may provide editable settings such as `memory_limit`, `upload_max_filesize`, `post_max_size`, `max_execution_time`, and `max_input_vars`.

Change only the setting that addresses a known requirement. Raising PHP memory may help an ecommerce import or page builder, for example, but setting excessively high limits across every site can hide inefficient code and allow a single process to consume more shared resources than expected.

If a setting is not available in cPanel, use the account's PHP INI editor if provided, or contact hosting support with the domain name, target PHP version, and the exact setting or extension needed. Avoid adding random directives to `.htaccess` files unless you know the server uses an Apache PHP handler that supports them. On PHP-FPM configurations, those directives may have no effect or cause an internal server error.

Confirm the browser is using the intended version

A temporary PHP information file can confirm the web-facing version. Create a file named `phpinfo.php` in the site's document root with this content:

```php

Open it in a browser and check the PHP Version line. Delete the file immediately afterward. It exposes server paths, loaded modules, and configuration details that should not remain publicly accessible.

Set PHP versions on a Linux VPS

A VPS gives you more flexibility, but it also makes the PHP stack your responsibility. First identify the operating system, web server, and PHP handler. Common setups include Apache with PHP-FPM, Nginx with PHP-FPM, OpenLiteSpeed with LSAPI, and control-panel-managed configurations.

If your VPS uses cPanel, Plesk, DirectAdmin, or another control panel, use that panel's supported PHP management feature instead of manually replacing packages. A panel may manage service templates, sockets, handlers, and security settings. Manual changes can be overwritten during updates or leave sites attached to the wrong handler.

Install a supported PHP-FPM version on Ubuntu or Debian

On a Debian-based VPS, package names usually include the PHP version. The following example installs PHP 8.3 with FPM, the command-line binary, and MySQL support:

```bash sudo apt update sudo apt install php8.3-fpm php8.3-cli php8.3-mysql sudo systemctl enable --now php8.3-fpm ```

Install additional version-matched packages as needed, such as `php8.3-curl`, `php8.3-mbstring`, `php8.3-xml`, `php8.3-zip`, `php8.3-gd`, or `php8.3-intl`. Package availability depends on the operating system release and configured repositories, so confirm that the PHP version you select receives security maintenance.

For a single site, create or adjust a dedicated PHP-FPM pool rather than changing every site at once. A pool can use its own Unix socket, process limits, user permissions, and PHP settings. This is especially useful on VPS servers hosting several customer sites or applications with different PHP requirements.

With Nginx, the site's server block must point to the socket used by the selected FPM pool. A typical directive looks like this:

```nginx fastcgi_pass unix:/run/php/php8.3-site.sock; ```

The exact socket name is defined in the FPM pool configuration. After checking the configuration syntax, reload the affected services:

```bash sudo nginx -t sudo systemctl reload nginx sudo systemctl reload php8.3-fpm ```

Apache can use PHP-FPM through `proxy_fcgi` and a Unix socket as well. The configuration differs by distribution and virtual-host layout, so verify the active Apache handler before editing files. Do not assume that enabling a new PHP package automatically makes Apache serve it.

Change the command-line PHP version separately

For deployments, Composer, Laravel Artisan commands, WordPress WP-CLI tasks, and cron jobs, check the command-line version:

```bash php -v ```

On many Debian and Ubuntu systems, you can select the default CLI binary with:

```bash sudo update-alternatives --config php ```

This changes the `php` command for the shell. It does not switch the PHP-FPM version used by websites. That distinction matters when a Composer install succeeds under one PHP version but the application fails in a browser under another.

For cron jobs, use the full path to the intended binary when possible, such as `/usr/bin/php8.3`, rather than relying on the default `php` command. It makes the job's runtime predictable after later package updates.

Verify the site and watch the logs

After the switch, confirm the PHP version through the website, then test the functions that matter to the application. Check administrative login, form submission, uploads, database-backed pages, API calls, scheduled tasks, and transactions where applicable.

If the site fails, review the PHP-FPM, web server, and application logs before making more changes. A 500 error may identify a missing extension, an unsupported function, a syntax issue in legacy code, an invalid PHP setting, or incorrect file permissions. A blank WordPress page often becomes easier to diagnose after enabling its application-level debug log temporarily, rather than displaying errors publicly.

Keep the previous supported PHP version installed until the new version has operated cleanly through normal traffic and scheduled jobs. Removing it immediately makes rollback slower if an infrequently used feature fails later.

Choose the management level that fits the workload

For a single business website, cPanel PHP selection is usually the quickest and lowest-risk option. It provides per-domain control without requiring web-server administration. For agencies and resellers, individual domain settings help separate customer compatibility needs while keeping account management straightforward.

A KVM VPS is a better fit when you need isolated PHP-FPM pools, custom extensions, application workers, deployment tooling, or direct control over Nginx and Apache. The trade-off is that updates, service monitoring, security patching, and rollback planning become part of your operational work. As an application grows, moving from managed cPanel hosting to a VPS or dedicated server can preserve that control without changing the provider relationship.

Treat a PHP version change as a controlled application update, not a dropdown setting to revisit only after an error. With a backup, a compatibility check, and verification of both web and CLI PHP, you can improve security and performance without disrupting the services your site depends on.