Linux9.5 配置httpd支持php

配置httpd支持php,apache调用了php的模块,使得httpd解析php

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

vim /usr/local/apache2.4/conf/httpd.conf //修改以下4个地方

ServerName 注释井号去掉

Require all denied 403的原因 ,改成granted。

AddType application/x-httpd-php .php 增加php解析语句,搜索AddType 在其后添加

DirectoryIndex index.html index.php 正价针对Php的索引,如果一个站点默认页为index.php,那么就得加上这个index.php的支持

可以通过命令/usr/local/apache2.4/bin/apachctl -t去检查配置文件是否正确, -t 换成 graceful重新加载配置

[root@chy002 php]# vi /usr/local/apache2.4/htdocs/1.php
<?php
phpinfo();
?>

一定要禁用iptables,否则解析不到1.php

/usr/local/apache2.4/bin/apachectl -t //测试语法

/usr/local/apache2.4/bin/apachectl -graceful //重新加载配置文件

/usr/local/apache2.4/bin/apachectl start //启动服务

netstat -lntp

curl localhost

vim /usr/local/apache2.4/htodcs/test.php //增加如下内容

<?php

echo 123;

?>

curl localhost/test.php