简体   繁体   English

MAC OSX:无法运行多个本地域

[英]MAC OSX: Cannot run multiple local domains

i am trying to add another local domain to my mac osx: 我试图将另一个本地域添加到我的Mac OSX:

No matter what i do when visiting say 'domainnumber2.dev' it always displays the first host in my list. 无论我做什么,当访问说“ domainnumber2.dev”时,它总是显示列表中的第一台主机。

If i swop them around in my httpd-vhosts file then i get the domainnumber2.dev site. 如果我在httpd-vhosts文件中四处乱转,那么我会得到domainnumber2.dev网站。 How can i run multiple localhost site on my mac. 我如何在Mac上运行多个localhost网站。

I have a simple set up as below: 我有一个简单的设置,如下所示:

  <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>

I have also had the more details set up adding the below for both 我还设置了更多详细信息,

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

In my hosts file i have: 在我的主机文件中,我有:

  ##
  # 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

which ever VirtualHost is first is the site that is served up VirtualHost最早出现的是服务的站点

I stumbled across this same problem... 我偶然发现了同样的问题...

In your httpd-vhosts.conf file (/private/etc/apache2/extra/httpd-vhosts.conf after showing hidden files) add the following for each domain... 在显示隐藏文件后的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>

Then restart apache. 然后重新启动apache。 Everything else you have seems to be the same as my setup. 您拥有的所有其他内容似乎与我的设置相同。

Make sure you have the correct permissions to be able to write the log files etc too. 确保您具有正确的权限也可以写入日志文件等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM