centos7搭建http服务器__指向外部地址

来源:互联网 发布:新疆公路计价软件 编辑:程序博客网 时间:2024/06/17 04:38

  今天准备centos7上搭建http服务器,遇到一个问题,花了两三个小时的时间才解决掉。

  使用yum安装了http服务后,编辑/etc/httpd/conf/httpd.conf ,启动http服务,打开浏览器,提示出错误信息:

Forbidden

You don't have permission to access / on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

  遇到这个问题让我很郁闷,网上百度的解决方式都是编辑配置文件,修改httpd.conf成 Allow from all

  1. <Directory />  
  2.     Options Indexes FollowSymLinks  
  3.     AllowOverride None 
  4.       Allow from all 
  5. </Directory></span>  
但是我想说,这种方式只是针对Apache/2.4.0版本以前的的解决方式,对于Apache/2.4.0+的方式根本不管用,所以正确的方式应该是将/etc/httpd/conf/httpd.conf配置文件中
<Directory />部分Require all denied


<Directory />
    AllowOverride none
    Require all denied
</Directory>改成

<Directory />
    AllowOverride none
    Require all granted
</Directory>然后重启httpd服务,这样就可以了。

1 0