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

本文介绍在CentOS7上配置HTTP服务器时遇到“Forbidden”错误的解决方法,适用于Apache 2.4.0及以上版本。通过修改httpd.conf文件中的权限设置,将Require all denied改为Require all granted。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  今天准备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服务,这样就可以了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值