mac OS X 升级到 Yosemite 后,apache 客户端被服务器配置拒绝

new*_*ode 12 apache-http-server php macos

我知道这看起来与其他问题相似,但 Yosemite 似乎在升级时更改了 apache 配置。我的错误日志显示“客户端被服务器配置拒绝:/Users/douglas/Sites/testpatient.php”

Apache 版本:MacBook-Pro:apache2 douglas$ apachectl -v 服务器版本:Apache/2.4.9 (Unix) 服务器构建:2014 年 9 月 9 日 14:48:20 我的 douglas.conf 文件是 644 root/wheel 和以下内容:

<Directory "/Users/douglas/Sites">
   Options Indexes Multiviews
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

我的 http.conf 有以下内容:

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User _www
Group _www

</IfModule>

...

DocumentRoot "/Library/WebServer/Documents"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Satisfy All
</Directory>

...

<Directory "/Library/WebServer/Documents">
#
# 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.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
#AllowOverride None
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
Satisfy All
</Directory>
Run Code Online (Sandbox Code Playgroud)

任何事情将不胜感激。我尝试回滚到以前的 http.conf 文件,但就需要加载的模块而言存在许多差异。我完全有可能错过了一个模块,但日志中没有抱怨。

小智 18

在您的用户 .conf (douglas.conf) 中替换:

Order allow,deny
Allow from all
Run Code Online (Sandbox Code Playgroud)

和:

Require all granted
Run Code Online (Sandbox Code Playgroud)

不同之处在于 apache 2.4 如何处理权限

http://httpd.apache.org/docs/2.4/upgrading.html


s4n*_*nji 13

我也有同样的问题,并通过这样做修复它:

  1. 通过在httpd.conf 中找到以下行并取消注释来加载 userdir 模块: LoadModule userdir_module libexec/apache2/mod_userdir.so Include /private/etc/apache2/extra/httpd-userdir.conf

  2. 编辑extra/httpd-userdir.conf,找到并取消注释以下行: Include /private/etc/apache2/users/*.conf

  3. 编辑users/*.conf,在选项行中的所有选项之前添加Require local和添加+(或-)字符,如下所示: <Directory "/Users/user/Sites/"> Options +Indexes +MultiViews +FollowSymLinks +SymLinksIfOwnerMatch +ExecCGI AllowOverride All Require local Order allow,deny Allow from all </Directory>