0

我正在尝试将另一个本地域添加到我的 mac osx:

无论我在访问时说“domainnumber2.dev”时做什么,它总是显示我列表中的第一个主机。

如果我将它们放在我的 httpd-vhosts 文件中,那么我会得到 domainnumber2.dev 站点。如何在我的 Mac 上运行多个 localhost 站点。

我有一个简单的设置如下:

  <VirtualHost *:80>
     ServerName mydomain.dev
     ServerAlias mydomain.dev
     DocumentRoot "/Users/UserName/Sites/mydomain/"
  </VirtualHost>

  <VirtualHost *:80>
     ServerName mydomainTwo.dev
     ServerAlias mydomainTwo.dev
     DocumentRoot "/Users/UserName/Sites/mydomainTwo/"
  </VirtualHost>

我还设置了更多详细信息,为两者添加了以下内容

  <Directory "/Users/UserName/Sites/mydomain/">
     DirectoryIndex index.php
     Options Indexes FollowSymLinks MultiViews
     AllowOverride all
     Order allow,deny
     allow from all
  </Directory>

在我的主机文件中,我有:

  ##
  # Host Database
  #
  # localhost is used to configure the loopback interface
  # when the system is booting.  Do not change this entry.
  ##
  127.0.0.1 localhost
  255.255.255.255   broadcasthost
  ::1             localhost 
  fe80::1%lo0   localhost
  127.0.0.1 mydomain.dev
  127.0.0.1 mydomainTwo.dev

VirtualHost 首先是提供服务的站点

4

1 回答 1

0

我偶然发现了同样的问题......

在您的 httpd-vhosts.conf 文件中(显示隐藏文件后的 /private/etc/apache2/extra/httpd-vhosts.conf)为每个域添加以下内容...

<VirtualHost *:80>
    ServerName mysubdomain.dev
    CustomLog "/root/to/site/logs/mysubdomain.dev-access_log" combined
    ErrorLog "/root/to/site/logs/mysubdomain.dev-error_log"
    DocumentRoot "/root/to/site/mysubdomain.co.uk"
    <Directory "/root/to/site/mysubdomain.co.uk">
        DirectoryIndex index.php
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

然后重启apache。您拥有的其他一切似乎都与我的设置相同。

确保您具有正确的权限,以便能够写入日志文件等。

于 2014-02-17T11:55:55.763 回答