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

来源:互联网 发布:高德软件股票行情 编辑:程序博客网 时间:2024/04/30 09:34

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
原创粉丝点击