配置httpd支持php
vim /usr/local/apache2.4/conf/httpd.conf
取消注释
ServerName www.example.com:80
将Require all denied 改为Require all granted
<Directory />
AllowOverride none
Require all granted
</Directory>
增加一行AddType application/x-httpd-php .php
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
增加索引页index.php
在DirectoryIndex index.html后面 增加索引页index.php
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
新建一个php文件
vi /usr/local/apache2.4/htdocs/1.php
代码:
<?php
phpinfo();
?>
浏览器打开访问192.168.188.2/1.php
如果显示是图片表格文件则正常;
如果显示为代码为错误;
/usr/local/apache2.4/bin/apachectl -M
看看有没有php5_module (shared)
如果没有php5的模块,那么检查是否有php5模块的文件libphp5.so
ls /usr/local/apache2.4/modules/libphp5.so
如果有libphp5.so文件,就检查httpd.cnf配置文件中是否加载
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
原文地址:http://blog.51cto.com/shuzonglu/2074448