Step 1: Download PHP from source http://php.net/downloads.php
Go to sourcecode and download
tar -zxvf php-5.5.38.tar.gz
Now we have to configure PHP for compilation process. There are hundreds of options which can be provided to configure script. These options include the option to specify where PHP should be installed, which functionality should be enabled, like functionality to access mysql databases from PHP and which extensions have to be compiled etc. To see a list of options supported by PHP configure, type:
$ ./configure –help
It’ll show a list of all options supported by the version of PHP that you are using.
To compile PHP as Apache shared module we have to provide path to apache apxs utility, which in our case was installed in /home/apache2/bin/ when we installed Apache.
$ ./configure –prefix=/home/apach2/php –with-apxs2=/home/apache2/bin/apxs –with-config-file-path=/home/apache2/php –with-mysql
First option –prefix=/home/apach2/php we want PHP to be installed in /home/apach2/php directory. Otherwise it’ll be installed in some default location (/usr/local).
Second option –with-apxs2 indicates that we want to install PHP as Apache 2 shared module.
Third option –with-config-file-path specifies that PHP should look for php.ini file in /home/apache2/php directory.
Fourth option –with-mysql enables support to access mysql databases through PHP.
You have to type make to compile PHP:
if Apache is running stop Apache:
Now we need to make some changes in Apache Configuration file in order to handle PHP files.
you need to add the following lines:
LoadModule php5_module modules/libphp5.so
AddType application/x-http-php .php
DirectoryIndex index.php index.html
Save this file and then start Apache:
Testing the PHP Installation
Now create a PHP file named info.php in /home/apach2/htdocs/
Save info.php and then access it via browser
If you get PHP Configuration. It means you are done. Thumbs Up.