MAC OS X:MAMP环境和虚拟主机 [英] MAC OS X: MAMP Environment & Virtual Hosts

查看:88
本文介绍了MAC OS X:MAMP环境和虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这里发生了什么,但是我正在MAC OS X上运行MAMP 1.9.在我的httpd.conf文件中,DocumentRoot设置为默认的htdocs路径.在htdocs文件夹中,我创建了许多子站点",以将它们设置为虚拟主机....我可以找到指定的路径,但是它们似乎都默认为我设置的第一个.

I'm not sure what's happening here, but I'm running MAMP 1.9 on MAC OS X. In my httpd.conf file, the DocumentRoot is set to the default htdocs path. Within the htdocs folder, I've created a number of "subsites" in an effort to set them up as Virtual Hosts.... I can get to the paths specified, but they all seem to default to the first one I set up.

基本上,我配置的第一个VirtualHost用于site1.localhost.com.此后,我已经配置了site2.localhost.com和site3.localhost.com.但是,转到最后两个地址中的任何一个,似乎总是将我重定向到site1.localhost.com.此外,仅访问localhost.com:8888也会拉起site1.localhost.com.我不确定我在哪里走错了一步,但是希望这里的人能够帮助我解决问题...哦,在对/etc/进行任何更改之后,我已经重新启动了apache等.主机或httpd.conf文件.

Essentially, the first VirtualHost I configured was for site1.localhost.com. I've since configured site2.localhost.com and site3.localhost.com. However, going to either of the last two addresses, always seems to redirect me to site1.localhost.com. Additionally, going to just localhost.com:8888 also just pulls up site1.localhost.com. I'm not sure where I made a mis-step, but hopefully someone here will be able to help me figure out the problem... Oh, and I have restarted apache etc., after any changes made to either the /etc/hosts or httpd.conf file.

在我的httpd.conf文件中(无论如何,相关部分……):

In my httpd.conf file (the relevant parts, anyway...):

#                                                                                                                                                                                                                                                                             
# DocumentRoot: The directory out of which you will serve your                                                                                                                                                                                                                
# documents. By default, all requests are taken from this directory, but                                                                                                                                                                                                      
# symbolic links and aliases may be used to point to other locations.                                                                                                                                                                                                         
#                                                                                                                                                                                                                                                                             
# MAMP DOCUMENT_ROOT !! Don't remove this line !!                                                                                                                                                                                                                             


 DocumentRoot "/Applications/MAMP/htdocs"

#                                                                                                                                                                                                                                                                             
# Note that from this point forward you must specifically allow                                                                                                                                                                                                               
# particular features to be enabled - so if something's not working as                                                                                                                                                                                                        
# you might expect, make sure that you have specifically enabled it                                                                                                                                                                                                           
# below.                                                                                                                                                                                                                                                                      
#                                                                                                                                                                                                                                                                             

#                                                                                                                                                                                                                                                                             
# This should be changed to whatever you set DocumentRoot to.                                                                                                                                                                                                                 
#                                                                                                                                                                                                                                                                             
<Directory "/Applications/MAMP/htdocs">

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/site1/"
ServerName site1.localhost.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site2/"
ServerName site2.localhost.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site3/"
ServerName site3.localhost.com
</VirtualHost>

在我的/etc/hosts文件中:

In my /etc/hosts file:

##                                                                                                                                                                                                                                                                            
# 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
127.0.0.1       site1.localhost.com
127.0.0.1       site2.localhost.com
127.0.0.1       site3.localhost.com
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

推荐答案

在您的httpd.conf文件中找到以下行并删除注释(#):

In your httpd.conf file find the following line and remove the comment (#):

 # NameVirtualHost * 

这篇关于MAC OS X:MAMP环境和虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆