我最近升级到了MAC OS X Yosemite,并且我的虚拟主机的apache配置无法正常工作。我按照@raoulsson(https://superuser.com/questions/827937/apache-problems-after-upgrading-to-yosemite)的建议升级了php:

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

并且还编辑了/etc/apache2/extra/httpd-vhosts.conf:
<VirtualHost *:80>
 ServerName test.local
 DocumentRoot "/Users/my-name/www/test"

 <Directory "/Users/my-name/www/test>
     AllowOverride All
     #Order allow,deny
     #Allow from all
    Require all granted

    RewriteEngine on

    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rewrite everything else to index.html to allow html5 state links
    RewriteRule ^ index.html [L]
 </Directory>

 <IfModule dir_module>
    DirectoryIndex index.html
 </IfModule>

 <Files ".ht*">
    Order deny,allow
    Deny from all
 </Files>
</VirtualHost>

现在,导航到我的一个虚拟主机(http://test.local)会给我消息“It Works” ,而不是显示我的网站。有人对我缺少的东西有想法吗?

编辑:
因此,事实证明问题出在/etc/apache2/httpd.conf中。我必须重新启用虚拟主机才能正常工作。并且由于我在上述虚拟主机中使用重写,因此我还必须加载重写引擎。
LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

不知道是否需要alias_module,但是我的配置现在可以正常工作,因此我将其保留下来。

最佳答案

首先,您需要删除某些行中的“#”。特别是,默认情况下不会导入vhost.conf文件。

喜欢 :

#LoadModule php5_module libexec/apache2/libphp5.so
#LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
#Include /private/etc/apache2/extra/httpd-vhosts.conf


LoadModule php5_module libexec/apache2/libphp5.so
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
Include /private/etc/apache2/extra/httpd-vhosts.conf

并在其他地方添加一些“#”
<Directory />
     AllowOverride none
     Require all denied
</Directory>


<Directory />
     #AllowOverride none
     #Require all denied
</Directory>

根据http://mallinson.ca/osx-web-development/

关于php - 优胜美地升级后损坏的Apache虚拟主机,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27058137/

10-10 23:40