Install PHP 8 on CentOS 7 (LightNode Server)
CentOS 7 ships with older PHP versions. This guide installs PHP 8.0 from the Remi repository and configures it for use with PHP-FPM, replacing the existing PHP 7.x setup.
Prerequisites
- CentOS 7 server with root access
- Existing PHP-FPM service (e.g.
php-fpm-7.0.12)
Steps
# Stop the existing PHP-FPM service
systemctl stop php-fpm-7.0.12.service
# Add EPEL and Remi repositories
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Install yum-utils and enable PHP 8.0
yum install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php80
# Install PHP 8.0 and extensions
yum install php php-cli php-mysql php-gd php-zip php-mbstring \
php-xml php-imagick php-fpm php-opcache php-intl php-redis
Update PHP-FPM Service Config
# Edit the init script to point to PHP 8.0 binaries
vim /etc/init.d/php-fpm-7.0.12
# Update these lines:
php_fpm_BIN=/usr/sbin/php-fpm
php_fpm_CONF=/opt/conf/php-7.0.12/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
# Restart the service
systemctl restart php-fpm-7.0.12.service
Verify
php -v
Should output PHP 8.0.x.
Notes
- The service name (
php-fpm-7.0.12) is specific to LightNode's custom setup — standard CentOS 7 usesphp-fpm. - Disable unused PHP 7.x extensions to avoid conflicts after switching.