Learn Devops tools online from the blog. Devops Institute Ahmedabad.

This article explains how to install PHP5 from source on Linux, Apache web server should already be installed.

Download PHP:-

Download the latest source code from http://in2.php.net/get/php-5.3.8.tar.gz/from/in.php.net/mirror link. Move the source to /usr/local/src and extract is as shown below.

# cd /usr/local/src

# wget http://in2.php.net/get/php-5.3.8.tar.gz/from/in.php.net/mirror

# tar xvf php-5.3.8.tar

Install Php:-

View all configuration options available for PHP using ./configure
–-help (two hyphen in front of help). The most commonly used option is
–-prefix={install-dir-name} to install PHP on a user defined directory.

# cd php-5.3.8
# ./configure --help

In the following example, PHP will be compiled and installed under the default location /usr/local/lib with Apache configuration and MySQL support.

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql

# make

# make install

# cp php.ini-dist /usr/local/lib/php.ini

Configure httpd.conf for PHP:-

Modify the /usr/local/apache2/conf/httpd.conf to add the following:

<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php

Make sure the httpd.conf has the following line that will get automatically inserted during the PHP installation process.

LoadModule php5_module modules/libphp5.so

Restart the apache as shown below:

# /usr/local/bin/apache2/apachectl restart

Verify PHP Installation:-

Create a test.php under /usr/local/apache2/htdocs with the following content

# vi vishalvyas.php
<?php phpinfo(); ?>

Go to http://localhost/vishalvyas.php , which will show a detailed information about all the PHP configuration options and PHP modules installed on the system.

Vishal Vyas

No comments:

Post a Comment