1.安装准备
(1)下载php包装包
http://cn2.php.net/downloads.php
(2)安装php
# tar -zxvf php-5.6.10.tar.gz # cd php-5.6.10 # ./configure --prefix=/usr/local/php --enable-opcache --enable-fpm --enable-mbstring --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs #注意指定apache安装路径及 mysql安装目录 # --with-mysqli=/usr/local/mysql/bin/mysql_config # make # make instal # make clean #清除编译后文件 # make distclean #彻底清除编译后文件 如果提示错误:configure: error: xml2-config not found. Please check your libxml2 installation. 解决方法: # yum install libxml2 # yum install libxml2-devel 都安装上
(3)Apache中加载php模块
# cp php.ini-dist /usr/local/php/lib/php.ini
修改php.ini。查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC
# vim /usr/local/apache2/conf/httpd.conf
查看是否有下面这句话,没有则添加
LoadModule php5_module modules/libphp5.so
找到“#AddType application/x-gzip .gz .tgz”添加
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
#加入后缀名过滤
AddHandler application/x-httpd-php .php
#或者以下配置应用过滤
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
(4)建立php测试文件
# vim /usr/local/apache2/htdocs/test.php
<?php
phpinfo();
?>
:wq
(5)重启Apache服务
# /usr/local/apache2/bin/apachectl restart
转载于:https://blog.51cto.com/yagetang/1670248