Compile and install PHP in Linux (ubuntu) environment.
Note: The installation path varies with operating systems!
1. Download php source code
$ Cd/usr/local/src
$ Wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror
2. decompress and install
$ Tar jxvf php-5.3.6.tar.bz2
$ Cd php-5.3.6/
$. /Configure -- prefix =/usr/local/php5 -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-mysql =/home/service/mysql -- with-zlib
$ Make
$ Make install
3. modify the apache configuration so that apache can identify the ". php" file.
$ Cd/etc/apach2
$ Vi apache2.conf
Add the following content at the end of the file:
1 LoadModule php5_module modules/libphp5.so 2
3 LoadModule php5_module lib/modules/libphp5.so 4
5 6
7 AddType application/x-httpd-php .php 8 AddType application/x-httpd-php .php5 9 AddType application/x-httpd-php-source .phps 10 AddType application/x-httpd-php-source .php5s 11 DirectoryIndex index.php 12 DirectoryIndex index.php5 13
Save and exit.
$/Usr/local/apache2/bin/apachectl restart
Restart apche and use the phpinfo () function to view the installed php module.
Appendix:
Meanings of configure parameters in php compilation in linux
Http://apps.hi.baidu.com/share/detail/34997687
Reference:
Http://blog.csdn.net/lanyd/article/details/6037927
Http://hi.baidu.com/comeon010/blog/item/983b29cbab80f912bf09e6a1.html
Http://hi.baidu.com/travel981cn/blog/item/2514bf34069031b0d0a2d30e.html
Http://www.phpbegin.com/html/96/n-4296.html
Http://www.cnblogs.com/qingfeng2010/archive/2011/01/07/1930333.html