在Mac上构建虚拟主机 - 无法正常工作

时间:2013-05-05 02:25:16

标签: php macos apache virtualhost vhosts

我正在尝试在Mac OS上构建虚拟主机,但它无法正常工作。

apache2 / error_log记录了以下消息

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Fri May 03 15:34:57 2013] [notice] Digest: generating secret for digest authentication ...
[Fri May 03 15:34:57 2013] [notice] Digest: done
[Fri May 03 15:34:58 2013] [notice] Apache/2.2.22 (Unix) DAV/2 configured -- resuming normal operations
[Fri May 03 15:35:16 2013] [error] [client 127.0.0.1] File does not exist: /usr/htdocs
[Fri May 03 15:35:16 2013] [error] [client 127.0.0.1] File does not exist: /usr/htdocs

浏览器返回此....

Not Found

The requested URL / was not found on this server.

Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch Server at dev.myhost.test Port 80

我花了很长时间试图解决这个问题。但我没有成功......

这是我的/etc/apache2/extra/httpd-vhosts.conf

NameVirtualHost *:80

<Directory "/Applications/XAMPP/htdocs/">
    Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory> 

<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/htdocs/smileflame"
    ServerName dev.smileflame.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/htdocs/teste"
    ServerName dev.myhost.test
</VirtualHost>

接下来是我的/ etc / hosts

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

127.0.0.1  dev.myhost.test

我希望这个vhost重定向到我的index.php ......但这不会发生...... 谁知道为什么????

1 个答案:

答案 0 :(得分:0)

不要使用相同的IP创建两个/etc/hosts条目。将别名放在同一行:

127.0.0.1       localhost dev.myhost.test
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost