Download:
Download php-4.x.xx (x.xx is version number), the PHP4 tarball, from www.php.net. If you intend to use ROCP and had already installed MySQL 4.1.xx, you should choose version 5.x.xx. Installation procedure for PHP5 might differ.
Preparation:
The following steps will help you install PHP in /usr/local/php. It is assumed that the tarball is in /home/user and you know how to get there. All instructions except unpack are issued from the untar directory of /home/user/php-4.x.xx.
Unpack:
-
# tar zxf php-4.x.xx.tar.gz
|
Change to PHP source directory:
-
Configure:
-
Note: The back slash tells Linux console to expect another line.
# ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql
|
Install:
If there is no error, proceed.
# make
|
Installation is done
# make install
|
Create PHP configuration file:
-
# cp php.ini-recommended /usr/local/php/lib/php.ini
|
Tell PHP the location of web directory:
- Edit php.ini:
-
# vi /usr/local/php/lib/php.ini
|
Find doc_root and change it to:
-
doc_root = "/usr/local/apache2/htdocs/"
|
You may edit php.ini further to enhance security. Otherwise, it is done.
Prepare PHP test script:
-
# vi /usr/local/apache2/htdocs/test.php
|
Add the line:
-
and save the file.
Testing PHP:
-
Point your browser to http://localhost/test.php and you will see PHP and your system data.
Remove the test script:
-
Do not skip this step!
# rm -f /usr/local/apache2/htdocs/test.php
|
Q&A
What is PHP?
PHP stands for Hypertext Pre-Processor. It is web scripting language.
Will the webserver reveal PHP codes?
No. Web pages will appear as HTML.
|