Current Location: Home> Latest Articles> How to Install and Configure PHP 5.5 on CentOS 6.5 – Complete Guide

How to Install and Configure PHP 5.5 on CentOS 6.5 – Complete Guide

gitbox 2025-06-28

Overview

In today's web environment, having a stable and efficient PHP environment is crucial. This guide provides detailed steps for installing and configuring PHP 5.5 on CentOS 6.5, ensuring that your PHP environment runs smoothly and securely.

System Preparation

Before starting, make sure your CentOS 6.5 system is updated to the latest version. You can update the system using the following command:

sudo yum update

Install Required Dependencies

Before installing PHP 5.5, you need to install some necessary dependencies. Run the following command:

sudo yum install httpd gcc make libxml2-devel bzip2-devel curl-devel

Add PHP 5.5 Yum Repository

Since PHP 5.5 is not available in the default CentOS 6.5 yum repository, you need to add a third-party yum repository. Run the following commands to add the repository:

sudo rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi
sudo curl -O http://rpms.remirepo.net/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6.rpm

Install PHP 5.5

Once the repository is added, you can install PHP 5.5 using the following command:

sudo yum --enablerepo=remi install php php-cli php-common

Verify Installation

After installation, you can verify that PHP is correctly installed by running the following command:

php -v

You should see an output similar to the following (version number may vary):

PHP 5.5.x (cli) (built: ...)

Configure PHP

After installation, you may need to perform some basic configurations to adjust PHP settings according to your needs. You can edit the PHP configuration file, typically located at /etc/php.ini:

sudo vi /etc/php.ini

Common Configuration Options

Here are some common configuration options:

  • upload_max_filesize - Adjust the file upload size limit.
  • post_max_size - Adjust the maximum size for POST data.
  • max_execution_time - Set the maximum execution time for scripts.

Find and modify the corresponding options in the configuration file, for example:

upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 30

Start Apache and Test PHP

After installing Apache and PHP, you need to start the Apache service and test it. Use the following command to start Apache:

sudo service httpd start

Next, create a PHP test file in the web root directory, usually located at /var/www/html:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now, you can visit http://your-server-ip/info.php in your browser to test if PHP is working correctly. If you see the PHP information page, the installation and configuration were successful.

Conclusion

By following these steps, you should be able to successfully install and configure PHP 5.5 on CentOS 6.5. Make sure to regularly check and update your PHP version to maintain security and performance.