【问题标题】:MAC OSX: Cannot run multiple local domainsMAC OSX:无法运行多个本地域
【发布时间】:2013-08-19 17:38:01
【问题描述】:

我正在尝试向我的 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 首先是提供服务的站点

【问题讨论】:

    标签: macos localhost virtualhost


    【解决方案1】:

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

    在您的 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。你所拥有的其他一切似乎都与我的设置相同。

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

    【讨论】:

    • 感谢这一点,不幸的是无法再测试,因为现在通过 Vagrant 等移动到虚拟机上更好地模仿我的实时服务器等再次感谢,但会尝试一次,如果我再次设置。
    猜你喜欢
    • 2013-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-02
    相关资源
    最近更新 更多