首页 > 开发 > Apache > 正文

让Apache和PHP结合配置过程

2020-07-28 15:06:34
字体:
来源:转载
供稿:网友
       总的来说,apache只是一个通用的服务器,可以配置各种页面,php的配置又相对会复杂一点,但是只要细心的去操作,问题也不会很大的。
       配置httpd支持PHP
 
  ServerName
 
  Requirealldenied
 
  AddTypeapplication/x-httpd-php.php//解析PHP
 
  DirectoryIndexindex.htmlindex.php
 
  [root@shuai-01~]#vim/usr/local/apache2.4/conf/httpd.conf
 
  
 
  修改
 
  找到ServerName行,取消注释
 
  ServerNamewww.example.com:80
 
  1
 
  找到Requireall,将Requirealldenied改为Requireallgranted,不然会返回403
 
  <Directory/>
 
  AllowOverridenone
 
  Requireallgranted
 
  </Directory>
 
  Requireallgranted
 
 
 
 
  找到
 
  AddTypeapplication/x-compress.Z
 
  AddTypeapplication/x-gzip.gz.tgz
 
  增加
 
  AddTypeapplication/x-httpd-php.php//增加这一行的目的是为了解析php文件
 
  1
 
  找到
 
  <IfModuledir_module>
 
  DirectoryIndexindex.html
 
  </IfModule>
 
 
 
  增加为
 
  <IfModuledir_module>
 
  DirectoryIndexindex.htmlindex.php//增加一个索引页index.php
 
  </IfModule>
 
  1
 
  2
 
  3
 
  检测配置文件语法是否有错误
 
  [root@shuai-01~]#/usr/local/apache2.4/bin/apachectl-t
 
  SyntaxOK
 
  
 
  重新加载配置文件,这个很重要(平时我们改完配置文件后,检查一下配置文件语法,然后就重启服务了。再重启服务前加上重新加载配置文件后,即使配置文件有错,也不会见你的服务进程杀掉)
 
  [root@shuai-01~]#/usr/local/apache2.4/bin/apachectlgraceful
 
 
 
  配置成功
 
  
 
  
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表