Current Location: Home> Latest Articles> Comprehensive Guide to Installing and Configuring PHP 7 on CentOS 6.5

Comprehensive Guide to Installing and Configuring PHP 7 on CentOS 6.5

gitbox 2025-08-04

Introduction

With continuous technological advancements, more developers and businesses aim to use the latest PHP versions to improve project performance and features. PHP 7 stands out with its excellent execution efficiency and new functionalities, becoming the preferred choice for many projects. This guide focuses on CentOS 6.5 and offers a detailed walkthrough for installing and configuring PHP 7 to help you quickly set up a stable and efficient PHP environment.

Preparation

Before starting, ensure your CentOS 6.5 system is fully updated to avoid installation issues. Run the following command to update your system:

sudo yum update

After updating, install the necessary tools and dependencies to prepare for the PHP 7 installation.

Install EPEL and Remi Repositories

PHP 7 is not available in CentOS 6.5’s default repositories, so you need to enable the EPEL and Remi third-party repositories. Use the following commands to install these repositories:

sudo yum install epel-release
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-6.rpm

Once installed, you can access PHP 7 packages from the Remi repository.

Enable PHP 7 Repository in Remi

Enable the PHP 7 repository from Remi and install PHP by running:

sudo yum --enablerepo=remi-php70 install php

This step ensures that PHP 7 is installed on your system.

Install PHP 7 and Common Extensions

With the PHP 7 repository enabled, install PHP along with commonly used extensions to cover various application needs:

sudo yum install php php-cli php-fpm php-mysql php-gd php-mbstring php-xml

These extensions include command line tools, FastCGI process manager, database support, and image processing capabilities suitable for most PHP projects.

Configure PHP 7

After installation, configure PHP to ensure it meets your requirements. The main PHP configuration file is located at:

/etc/php.ini

Edit this file using a text editor to adjust settings as needed. For example, you can change the maximum upload file size and set the timezone:

upload_max_filesize = 20M
date.timezone = "Asia/Shanghai"

Start and Enable PHP-FPM Service

After configuring PHP, start the PHP-FPM service and enable it to launch on boot:

sudo service php-fpm start
sudo chkconfig php-fpm on

Verify the service is running correctly by checking its status with:

sudo service php-fpm status

Verify PHP 7 Installation

To confirm that PHP 7 is properly installed and working, create a test file named info.php in your web server’s root directory with the following content:

<?php
phpinfo();
?>

Then, access http://your_server_ip/info.php in your browser. If the PHP info page appears, your installation and configuration were successful.

Conclusion

This guide covered the complete process of installing and configuring PHP 7 on CentOS 6.5. From system updates, adding repositories, installing PHP and extensions, to configuration tweaks and service management, each step ensures a smooth setup. Following these instructions, you will have a robust PHP 7 environment that enhances your applications’ performance and security.