首页 文章

升级到Yosemite后,Apache配置中断

提问于
浏览
7

昨天我升级到Yosemite,现在我的本地Web开发配置不再适用了 .

我设法在 /Users/user/public_html 下设置了一个userdir,我可以通过 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 ,它会显示消息"It works!" . 如果我去 localhost/user 根本不加载,如果我尝试访问其中一个网站相同 .

我错过了任何文件吗?在apache日志中,它甚至不显示任何错误 .

2 回答

  • 18

    OS X 10.10 Yosemite在小牛队中使用Apache 2.4而不是Apache 2.2 .
    配置的主要区别在于你必须更换......

    Order allow,deny
    Allow from all
    

    ...与...

    Require all granted
    

    有关更多详细信息,请参阅Apache doc的手册Upgrading to 2.4 from 2.2 .

    UPDATE:
    请注意,升级OS X后,您通常会发现旧配置文件作为Yosemite编写的新配置文件旁边的备份 . 它们被标记为例如httpd.conf.pre-update和/或httpd.conf~previous,可以在与新配置相同的路径中找到(例如在/ private / etc / apache2中) .

  • 1

    在尝试解决这个问题6个小时后,我终于能够使这个工作了 . 我编辑了httpd.conf,httpd-userdir.conf,httpd-vhosts.conf等无济于事 . 从yosemite配置中保留所有这些未编辑的文件,最终对我有用的是编辑位于 /Library/Server/Web/Config/apache2/ 的httpd_server_app.conf,添加以下内容(对于每个站点),如下所示:

    <Directory />
    	Options +FollowSymLinks
    	AllowOverride All
    	Order deny,allow
    	Deny from all
    </Directory>
    
    <Directory "/Library/Server/Web/Data/Sites/Default/">
    	Options +Indexes +FollowSymLinks +MultiViews
    	AllowOverride All
    	Order allow,deny
    	Allow from all
    </Directory>
    
    <Directory "/Library/Server/Web/Data/Sites/[OTHER SITE DIRECTORY]/">
    	Options +Indexes +FollowSymLinks +MultiViews
    	AllowOverride All
    	Order allow,deny
    	Allow from all
    </Directory>
    

    Make sure if you use textedit to edit this file you undo the automatic insertion of the slanted quotation marks otherwise you will get a unicode error message.

    希望这可以帮助!

相关问题