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 -ySince the default CentOS repositories don’t include PHP 5.6, begin by enabling the EPEL repository:
sudo yum install epel-release -yRemi 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 -yOnce Remi is installed, enable the PHP 5.6 repository specifically:
sudo yum-config-manager --enable remi-php56Now you can proceed with installing PHP 5.6 along with commonly used modules:
sudo yum install php php-cli php-fpm php-mysql -yTo confirm PHP was installed correctly, check the version with the following command:
php -vYou 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.iniTypical 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-fpmsudo systemctl enable php-fpmBy 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.