Running a supported PHP version improves security and compatibility for WordPress and modern applications. On VPS and dedicated servers with SSH access, you can install or switch PHP versions using your distribution’s packages or version managers. This guide covers CLI checks, package-based upgrades, and switching the version used by the web server.
Check Current PHP
From SSH, inspect CLI and loaded modules:
php -v
php -m | head
which phpCLI PHP may differ from PHP-FPM or Apache’s mod_php. Confirm the SAPI your site uses in the vhost or pool config. See PHP.net installation guide.
Install PHP Packages (RHEL/Alma/Rocky)
Enable Remi or your host’s PHP repository if required, then install the desired version and extensions:
sudo dnf module list php
sudo dnf module enable php:remi-8.2 -y
sudo dnf install -y php php-cli php-fpm php-mysqlnd php-xml php-mbstring php-curl php-zip php-gd php-intlOn Debian/Ubuntu with Sury or Ondřej PPA:
sudo apt-get install -y php8.2 php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring php8.2-curl php8.2-zip php8.2-gdConfigure PHP-FPM
For NGINX or Apache with FPM, enable and start the matching pool:
sudo systemctl enable php-fpm
sudo systemctl start php-fpm
sudo systemctl status php-fpmPool files often live under /etc/php-fpm.d/. Point your site’s vhost fastcgi_pass (NGINX) or proxy (Apache) to the correct socket, e.g. /run/php-fpm/www.sock.
NGINX fastcgi_pass Example
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/www.sock;
}Set Default Alternatives (Multi-Version)
When multiple PHP versions are installed:
sudo alternatives --config php
sudo alternatives --config php-fpmphp.ini Settings
Adjust limits in the correct php.ini (CLI vs FPM may differ):
php --ini
sudo nano /etc/php.iniCommon WordPress-friendly values:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120sudo systemctl reload php-fpm. WordPress requirements are listed in the WordPress requirements article.
Verify Web PHP
Create a temporary info.php in the site docroot only for testing, then remove it:
<?php phpinfo();Load it over HTTPS, confirm version and extensions, then delete the file immediately.
Summary
Check CLI and FPM versions separately, install PHP and required extensions from your distro or Remi/Sury, align FPM pools with NGINX/Apache vhosts, tune php.ini, and verify via a temporary phpinfo before removing it. SerVee IT managed servers often use predefined PHP handlers—open a support request if you need a version not offered in your plan.