zgdy 发表于 2018-11-20 13:51:42

apache配置解析php

  用vim打开apache的核心配置文件
vim /usr/local/apache2/conf/httpd.conf  找到下面这段文字
  
    Options FollowSymLinks
  
    AllowOverride None
  
    Order deny,allow
  
    Deny from all
  

  把deny from all 改为allow from all,若不修改访问网站会是禁止访问,显示403!
  找到:
AddType application/x-gzip .gz .tgz  在其下面添加:
ddType application/x-httpd-php .php    //添加支持对php脚本解析  找到:
  
    DirectoryIndex index.html
  

  把中间那一行改为:
DirectoryIndex index.html index.htm index.php//增加对php的索引  在找到
#ServerName www.example.com:80  把其改为:
ServerName localhost:80       //注意把前面的“#”去掉如果不去掉#时,启动时会有警告信息,但是没有影响,仍可以启动apache用/usr/local/apache2/bin/apachectl -t检测,看配置是否有问题,如果显示Syntax OK则说明配置没问题!/usr/local/apache2/bin/apachectl start 启动apacche  测试是否能够解析php
写如一个php文件:vim /usr/local/apache2/htdocs/1.php  

  保存后在浏览器输入http://你的ip/1.php看是否会显示写入的内容即 “php running”
  如果访问的过程中出现有问题,可能是防火墙未关闭的原因:
iptables -F   清楚防火墙的规则,  
service iptables save//保存防火墙的规则


页: [1]
查看完整版本: apache配置解析php