httpd主配置文件/usr/local/apache2.4/conf/httpd.conf

 vim /usr/local/apache2.4/conf/httpd.conf //修改以下4个地方
ServerName
Require all denied
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php

具体操作:
1,打开这一行ServerName www.example.com:80
2,Require all denied改为Require all granted
3,AddType application/x-compress .Z
     AddType application/x-gzip .gz .tgz
	  在上面两行下面加上这一行,不增加这一行php没办法解析
	  AddType application/x-httpd-php .php
4,DirectoryIndex index.html改为DirectoryIndex index.html index.php 增加一个索引页

测试语法

/usr/local/apache2.4/bin/apachectl -t

启动服务

/usr/local/apache2.4/bin/apachectl start 
 netstat -lntp 
 curl localhost
 
如果 curl 报错 Empty reply from server
找到并修改如下
EnableMMAP off
EnableSendfile off

编辑测试的php文件

vim /usr/local/apache2.4/htodcs/test.php //增加如下内容
<?php
phpinfo();
?>

curl测试

curl localhost/test.php

/usr/local/php/bin/php -i |less

无法解析检查方法

1,/usr/local/apache2.4/bin/apachectl -M查看有没有加载php5_module (shared)模块
2,如果没有加载,看看/usr/local/apache2.4/modules/下有没有libphp5.so这个模块
3,如果有文件并没有显示,查看apache配置文件/usr/local/apache2.4/conf/httpd.conf有没有加载libphp5.so
4,检查配置文件有没有加这一行AddType application/x-httpd-php .php
5,/usr/local/apache2.4/htdocs是否granted