标签:11.14/15 Apache和PHP 11.16/17 Apache默认虚拟
11.14/15 Apache和PHP结合(4)搜索DirectoryIndex index.html,改为如下:
DirectoryIndex index.html index.php
验证apache是否支持解析PHP(测试PHP脚本)
vim /usr/local/apache2.4/htodcs/test.php //增加如下内容
<?php
echo 123;
?>
在浏览器中输入PHP所在虚拟机IP,如果能顺利打打页面则说明apache支持解析PHP
curl localhost/test.php
遇到PHP解析不了问题的排查方法:
(1)查看apache是否有加载PHP模块
/usr/local/apache2.4/bin/apachectl -M
(2)查看是否有这个PHP模块
ls /usr/local/apache2.4/modules/libphp5.so
(3)检查配置文件里是否有加载PHP模块的语句
vim /usr/local/apache2.4/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
(4)检查配置文件里是否有AddType..的语句
vim /usr/local/apache2.4/conf/httpd.conf
AddType application/x-httpd-php .php
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/abc.com"
ServerName abc.com
ServerAlias www.abc.com www.123.com
ErrorLog "logs/abc.com-error_log"
CustomLog "logs/abc.com-access_log" common
</VirtualHost>
/usr/local/apache2.4/bin/apachectl graceful
结论:
标签:11.14/15 Apache和PHP 11.16/17 Apache默认虚拟
原文地址:http://blog.51cto.com/13517946/2074379