Compile and install php, decompress php-to/usr/local/src, and enter this directory for compilation.
Cd/usr/local/src/php-5.2.9
#. /Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql =/usr/local/mysql -- with-config- file-path =/usr/local/php
Note: -- with-apxs2 =/usr/local/apache2/bin/apxs: use apache's apxs tool to compile php into a module of apache
-- With-mysql =/usr/local/mysql: combined with mysql
Make & make install
Cp php. ini-dist/usr/local/php. ini
If everything goes well, apache2/modules should have a libphp5.so file.
Add php support for apache
Edit the/usr/local/apache2/conf/httpd. conf file
In AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add a line later
AddType application/x-httpd-php. php (note that there must be spaces in this area)
At the end of the DirectoryIndex command, add index. php
Test Apache and php support
The apache control file is under/usr/local/apache2/bin.
Apachectl stop apache service
Apachectl start apache service
Complete a php test page 1.php with one line:
, Put it in/usr/local/apache2/htdocs