用vim打开apache的核心配置文件
| 1 | vim /usr/local/apache2/conf/httpd.conf |
找到下面这段文字
| 123456 | |
把deny from all 改为allow from all,若不修改访问网站会是禁止访问,显示403!
找到:
| 1 | AddType application/x-gzip .gz .tgz |
在其下面添加:
| 1 | ddType application/x-httpd-php .php |
找到:
| 123 | |
把中间那一行改为:
| 1 | DirectoryIndex index.html index.htm index.php |
在找到
| 1 | #ServerName www.example.com:80 |
把其改为:
| 1 | ServerName localhost:80 |
| 1 | 用/usr/local/apache2/bin/apachectl -t检测,看配置是否有问题,如果显示Syntax OK则说明配置没问题! |
| 1 | /usr/local/apache2/bin/apachectl start 启动apacche |
测试是否能够解析php
| 1234 | 写如一个php文件:vim /usr/local/apache2/htdocs/1.php |
保存后在浏览器输入http://你的ip/1.php看是否会显示写入的内容即 “php running”
如果访问的过程中出现有问题,可能是防火墙未关闭的原因:
| 12 | iptables -F 清楚防火墙的规则, |



