Linux下编译安装PHP
注: 不同操作系统下, 安装路径不同,请注意!
1. 下载php源码
$cd /usr/local/src
$wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror
2. 解压缩并安装
$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. 修改apache配置,使得apache可以识别".php"文件
$cd /etc/apach2
$vi apache2.conf
在文件末尾增加如下内容:
1 LoadModule php5_module modules/libphp5.so 23 LoadModule php5_module lib/modules/libphp5.so 4 5 67 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
保存退出.
$/usr/local/apache2/bin/apachectl restart
重启apche,然后用phpinfo()函数就能看到安装的php模块了.
附:
linux下编译php中configure参数具体含义
http://apps.hi.baidu.com/share/detail/34997687
参考文档:
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