1. 下载
官网:http://php.net/downloads.php
wget http://cn2.php.net/get/php-5.6.7.tar.gz/from/this/mirror
2. 安装
tar -zxvf php-5.6.7.tar.gz
cd php-5.6.7
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib
--enable-track-vars --with-xml --with-mysql
需要先安装apache:http://www.cnblogs.com/liuchao102/p/4399296.html
需要先安装mysql:http://www.cnblogs.com/liuchao102/p/4409415.html (安装php的时候最好把mysql扩展也安装了,一步到位,后期再加mysql扩展的时候有点麻烦)
make && make install
3. 配置apache
vi /usr/local/apache/conf/httpd.conf
1. LoadModule中添加:
LoadModule php5_module modules/libphp5.so
2. AddType application/x-gzip .gz .tgz 下面添加php支持
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps3. 在 DirectoryIndex 后面添加 index.php 以便Apache识别PHP格式的index
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>4. 重启apache服务
4. 新建php测试文件
vi /usr/local/apache/htdocs/info.php
<?php
phpinfo();
?>
5. 测试一下
http://192.168.88.117/info.php
6. 效果
7. 安装的时候出现问题
执行./configure 的时候出现
configure: WARNING: unrecognized options: --enable-track-vars, --with-xml
解决办法 : 没有理会这个警告,继续make && make install 安装完成,不知道这个警告怎么回事