Although newer PHP versions are available, many legacy systems and frameworks still rely on PHP 5.6. Installing it on CentOS 7 ensures compatibility and stable performance for such projects.
Before proceeding, it's best to update all existing packages to avoid dependency issues:
sudo yum update -y
Since the default CentOS repositories don’t include PHP 5.6, begin by enabling the EPEL repository:
sudo yum install epel-release -y
Remi provides access to multiple PHP versions, including older releases like 5.6. Use the command below to install it:
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
Once Remi is installed, enable the PHP 5.6 repository specifically:
sudo yum-config-manager --enable remi-php56
Now you can proceed with installing PHP 5.6 along with commonly used modules:
sudo yum install php php-cli php-fpm php-mysql -y
To confirm PHP was installed correctly, check the version with the following command:
php -v
You should see output indicating PHP 5.6.x, confirming a successful setup.
The main configuration file is located at /etc/php.ini. Open it with a text editor to make changes:
sudo vi /etc/php.ini
Typical edits include adjusting memory limits, upload file size limits, and other performance-related settings.
PHP-FPM handles PHP requests for web servers. Start the service and enable it to run at boot:
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
By following this guide, you’ve successfully installed PHP 5.6 on CentOS 7. This version remains crucial for older applications and continues to serve in many production environments. Be sure to configure settings according to your specific project needs for optimal performance.