How to compile and install PHP 5.6 on CentOS 6.x
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.
Small world. Big idea!
- Welcome to visit the knowledge base of SRE and DevOps!
- License under CC BY-NC 4.0
- No personal information is collected
- Made with Material for MkDocs and generative AI tools
- Copyright issue feedback me#imzye.com, replace # with @
- Get latest SRE news and discuss on Discord Channel