【问题标题】:Building Virtual Host on Mac - Is not working在 Mac 上构建虚拟主机 - 不工作
【发布时间】:2013-04-29 03:33:42
【问题描述】:

我正在尝试在我的 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...但这没有发生... 有人知道为什么吗???

【问题讨论】:

  • 您在浏览器中使用什么 URL 来请求页面?

标签: php macos apache virtualhost vhosts


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-11-18
    • 2014-07-04
    • 2013-04-10
    • 1970-01-01
    • 2017-07-05
    • 2016-11-07
    • 2018-05-09
    相关资源
    最近更新 更多