Current Location: Home> Latest Articles> Comprehensive Guide to Installing PHP 5.6 on CentOS 7

Comprehensive Guide to Installing PHP 5.6 on CentOS 7

gitbox 2025-06-27

Why Use PHP 5.6 on CentOS 7

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.

Update System Packages

Before proceeding, it's best to update all existing packages to avoid dependency issues:

sudo yum update -y

Install the EPEL Repository

Since the default CentOS repositories don’t include PHP 5.6, begin by enabling the EPEL repository:

sudo yum install epel-release -y

Add the Remi Repository

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

Enable the PHP 5.6 Repository

Once Remi is installed, enable the PHP 5.6 repository specifically:

sudo yum-config-manager --enable remi-php56

Install PHP 5.6 and Common Modules

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

Verify the PHP Installation

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.

Edit the PHP Configuration File

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.

Start and Enable PHP-FPM

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

Conclusion

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.