Apache服务器的启动以及 403 forbidden 问题的解决

1:判断本地计算机的Apache服务器是否启动

在浏览器地址栏中输入:localhost

通过是否有返回结果,即可判断本地的Apache是否正常工作

2:启动 sudoapachectl -k start,启动成功如下图所示;


     重新启动 sudo apachectl -k restart

                        

3:修改apache的默认文档目录

首先,定位到文档中:cd /etc/apache2/,sudo vimhttpd.conf,/DocumentRoot,

接下来需要修改DocumentRoot和Directory

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

#DocumentRoot "/Library/WebServer/Documents"

DocumentRoot "/Users/aaron/sites"

#<Directory "/Library/WebServer/Documents">

<Directory "/User/aaron/sites">

修改完成后,在site目录下添加html文件,如果没问题的话,在浏览器输入localhost或者127.0.0.1就能显示自己添加的html文件了。

4:解决apache 403 forbidden 问题的解决

a)(旧版本403问题)的修改:

打开 apache的配置文件httpd.conf,找到这段代码:

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

有时候由于配置了php后,这里的“Deny from all”已经拒绝了一切连接。把该行改成“allow from all”,修改后的代码如下,问题解决。

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

b)(新版本403问题)的修改,新版本有所不同,

打开 apache的配置文件httpd.conf,找到这段代码:

# Deny access to the entirety of your server's filesystem. You must

# explicitly permit access to web content directories in other

# <Directory> blocks below.

#

<Directory />

    AllowOverride none

    Require all denied

</Directory>

将其中的Require all denied修改为Require all granted就行了

<Directory />

    AllowOverride none

    Require all granted

</Directory>


成功后如下图所示







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值