我知道这看起来与其他问题类似,但 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>
我的 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>
任何帮助都会很感激。我尝试回滚到之前的 http.conf 文件,但需要加载的模块有很多不同。完全有可能我错过了一个模块,但日志中没有投诉。
答案1
在您的用户 .conf(douglas.conf)中替换:
Order allow,deny
Allow from all
和:
Require all granted
不同之处在于 apache 2.4 处理权限的方式
答案2
我遇到了同样的问题,并通过以下方式解决了它:
加载 userdir 模块:编辑httpd配置文件(
/etc/apache2/httpd.conf
在 MacBook 上)并取消注释以下行:LoadModule userdir_module libexec/apache2/mod_userdir.so
和
Include /private/etc/apache2/extra/httpd-userdir.conf
编辑httpd-用户目录(在
/etc/apache2/extra/httpd-userdir.conf
),找到并取消注释以下行:Include /private/etc/apache2/users/*.conf
编辑配置文件用户/*.conf,在选项行的所有选项前添加
Require local
and+
(或)字符:-
<Directory "/Users/user/Sites/"> Options +Indexes +MultiViews +FollowSymLinks +SymLinksIfOwnerMatch +ExecCGI AllowOverride All Require local Order allow,deny Allow from all </Directory>
答案3
我在 Mavericks 上也遇到了同样的问题,不过是在几天前应用了安全更新之后。Mavericks 仍在使用 Apache 2.2,所以这不是 chrisMc 提到的配置问题,不过看起来他是对的,你也需要更改它。
就我而言,我首先通过注释掉之前添加的 Homebrew PHP 5.4 模块行来解决核心问题。在httpd.conf
:
#LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
而是选择我之前注释掉的默认 PHP 模块:
LoadModule php5_module libexec/apache2/libphp5.so
这解决了问题,但为什么自制版本崩溃了,我想可能是编译时所针对的系统库在安全更新中进行了更新。运行时我收到有关未加载库php -v
的警告。icu4c
因此,我只需重新编译 PHP,它就可以再次正常工作。就我而言,我只是这样做
brew uninstall php54
brew install php54
然后可以再次启用 Homebrew 模块。
答案4
取消httpd.conf
注释:
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
并/etc/apache2/extra/httpd-userdir.conf
取消注释:
Include /private/etc/apache2/users/*.conf
然后重新启动 Apache。