Skip to content

How to compile and install PHP 5.6 on CentOS 6.x

homepage-banner

Compile and install PHP 5.6 on CentOS 6.x

PHP is a popular server-side scripting language that is used to develop web applications. CentOS 6.x is a widely used Linux distribution that is known for its stability and reliability. In this guide, we will walk you through the steps to compile and install PHP 5.6 on CentOS 6.x.

Prerequisites

  • A CentOS 6.x server with root access.
  • Basic knowledge of Linux command line.

Step 1: Install required dependencies

Before we start compiling PHP, we need to install some required dependencies. Open the terminal and type the following command:

yum install gcc make openssl-devel libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

This command will install all the necessary dependencies required to compile PHP.

Step 2: Download PHP 5.6

Next, we need to download the PHP 5.6 source code from the official website. Open the terminal and run the following command:

wget https://www.php.net/distributions/php-5.6.40.tar.gz

This command will download the PHP 5.6 source code to your server.

Step 3: Extract the source code

Once the download is complete, we need to extract the source code. Run the following command to extract the source code:

tar -zxvf php-5.6.40.tar.gz

This command will extract the source code to a new directory named ‘php-5.6.40’.

Step 4: Configure PHP

Now that we have extracted the source code, we need to configure PHP for our server. Run the following command to configure PHP:

cd php-5.6.40
./configure --prefix=/usr/local/php5.6 --with-config-file-path=/usr/local/php5.6/etc --with-apxs2=/usr/sbin/apxs --enable-mbstring --with-curl --with-openssl --with-zlib --with-gettext --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib --with-mcrypt

This command will configure PHP with the required options.

Step 5: Compile PHP

Once the configuration is complete, we can now compile PHP. Run the following command to compile PHP:

make

This command will compile PHP with the options we configured in the previous step.

Step 6: Install PHP

After the compilation is complete, we can now install PHP. Run the following command to install PHP:

make install

This command will install PHP on your server.

Step 7: Verify PHP installation

Finally, we can verify the PHP installation by running the following command:

/usr/local/php5.6/bin/php -v

This command will display the PHP version installed on your server.

Congratulations! You have successfully compiled and installed PHP 5.6 on CentOS 6.x. You can now use PHP to develop your web applications.

Leave a message