【发布时间】:2014-12-16 13:28:05
【问题描述】:
昨天我升级到 Yosemite,现在我的本地 Web 开发配置不再工作了。
我设法在/Users/user/public_html 下设置了一个用户目录,我可以通过localhost/~user/websitename 访问所有网站。没什么特别的,但我花了一些时间来配置。
查看 apache 目录,我看到许多文件被替换,保留备份。我尝试再次使用我的设置恢复文件,但仍然无法正常工作。也许我遗漏了一些我不记得的文件。
这是 httpd-userdir.conf:
# Settings for user home directories
#
# Required module: mod_userdir
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received. Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html
#
# Users might not be in /Users/*/Sites, so use user-specific config files.
#
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
RegisterUserSite customized-users
</IfModule>
<Directory "/Users/*/public_html/">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>
然后在 http.conf 我启用了一些模块:
Include /private/etc/apache2/extra/httpd-userdir.conf
LoadModule userdir_module libexec/apache2/mod_userdir.so
还有这个:
DocumentRoot "/Users/user/public_html"
Directory "/Users/user/public_html">
#
# 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 all
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
如果我只是尝试访问localhost,它会显示消息“它有效!”。如果我去localhost/user 根本不会加载,如果我尝试访问其中一个网站也是一样的。
我错过了任何文件吗?在 apache 日志中它甚至没有显示任何错误。
【问题讨论】:
-
Yosemite 将 Apache 从 2.2 升级到 2.4。配置已更改。您是否启用了 mod_userdir 模块?此外,您还需要更改“订单”和“允许”指令。您可能需要查看升级指南httpd.apache.org/docs/2.4/upgrading.html
-
未来的读者可能希望以正确的方式从installing Apache, PHP, and MySQL on Mac OS X Yosemite开始。
标签: php macos apache osx-yosemite