If you want to install PHP on Linux or any version of Unix, here is a list of prerequisites:
PHP source is at: http://www.php.net/downloads.php
The latest Apache version is at: http://httpd.apache.org/download.cgi
A Database that supports PHP, for example: MySQL, Oracle, ...
Any other supported software that PHP must connect to, for example: Mail Server, BCMath package, JDK, ...
An ANSI C compiler.
You can download GNU from: http://www.gnu.org/software/make
Here are the steps to install Apache and PHP5 on Linux or Unix. If the PHP or Apache version is different, then you should check it carefully.
Once you've unzip the Apache source, unless you have any other reason, the standard location is /usr/local.
gunzip -c apache_1.3.x.tar.gz tar -xvf apache_1.3.x.tar
Build Apache Server as follows:
cd apache_1.3.x ./configure --prefix=/usr/local/apache --enable-so make make install
After unzip the PHP source, unless you have other reasons, the standard location is /usr/local.
gunzip -c php-5.x.tar.gz tar -xvf php-5.x.tar cd php-5.x
Configure and build PHP, assuming you are using MySQL Database.
./configure --with-apxs=/usr/sbin/apxs \ --with-mysql=/usr/bin/mysql make make install
Install the php.ini file. Edit this file to get configuration directives:
cd ../../php-5.x cp php.ini-dist /usr/local/lib/php.ini
Tell Apache Server where you want to put the files and extensions you want to identify the PHP file. A .php extension is standard, but you can use .html, .phtml, or whatever you want.
Go to your HTTP configuration files (/usr/local/apache/conf or whatever your path is).
Open httpd.conf with a Text Editor.
Search from DocumentRoot (which will appear twice) and change both paths for the directory where you want to serve the files (in this case, / home / httpd). We recommend a Home Directory instead of / usr / local / apache/ htdocs by default, because it's more secure, but it's not a Home Directory. You will keep all PHP files in this directory.
Add at least one PHP extension directive, as shown below in the first line of code that follows. In line two, we also add a second Handler for all HTML files parsed as PHP.
AddType application/x-httpd-php .php AddType application/x-httpd-php .html
Restart the Server. Every time you change the HTTP configuration or the php.ini file, you must stop and start the server again.
cd ../bin ./apachectl start
Set the Root Directory's Permission to world-executable. The actual PHP file in this directory should be world-executable (644). If necessary, replace / home / httpd with Document Root as shown below.
chmod 755 /home/httpd/html/php
Open a Text Editor. Type <?php phpinfo (); ?>.
Save this file in Document Root as info.php in your Web Server.
Start any web browser and browse this file. You should always use an HTTP Request (http://www.testdomain.com/info.php or http://localhost/info.php or http://127.0.0.1/info.php) instead of a filename (/home/httpd/info.php) so that the file is parsed correctly.
You should observe a long information sheet about your PHP installation notice.