您的位置:首页 > 运维架构 > Apache

Mac Os自带Apache修改自定义项目配置报403 Forbidden, You don't have permission to access/on this server解决

2017-04-25 22:56 806 查看
Mac OS X 系统已经集成了 Apache+PHP 环境,依次进入“系统偏好设置 -> 共享” ,开启“Web 共享”,就可以打开 Apache。

但新版的 Mac OS X 中,苹果取消了这个共享功能的图形界面,只能从命令行开启。

2

在终端里输入命令,启动 Apache: sudo apachectl start

关闭 Apache: sudo apachectl stop

重启 Apache:sudo apachectl restart

查看 Apache 版本:httpd -v

Mac OS X 10.9.X 中的 Apache 版本信息:

Server version: Apache/2.2.26 (Unix) Server built:   Dec 10 2013 22:09:38

3

启用 Apache 之后,在浏览器中访问 http://localhosthttp://127.0.0.1,如果出现“It works!”就表示运行正常。

以上内容来自http://jingyan.baidu.com/article/0aa22375b553a488cc0d64b5.html ,

不过我在修改/etc/apache2/httpd.conf配置,将默认的项目路径由 /Library/WebServer/Documents/ 都替换成自己的路径,比如 /Users/juliana/myphpspace

重启apache后,报403 Forbidden,You don't have permission to access/on this server ,解决方案:

1).将#<Directory />

#   AllowOverride none

#  Require all denied

#</Directory>

改为:<Directory />

    Options  Indexes  FollowSymLinks

    AllowOverride None

   Order deny,allow

    Allow from all

</Directory>

2).将AllowOverride None改为AllowOverride
All

DocumentRoot "/Users/juliana/newsp/testing/Test/www"
<Directory "/Users/juliana/newsp/testing/Test/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options     # for more information.
    #
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    # AllowOverride None

      AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

然后重启apache服务器,就正常了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  apache php mac os x
相关文章推荐