Mamp+虚拟主机?为啥我只是进入 localhost/mamp 文档根目录
Posted
技术标签:
【中文标题】Mamp+虚拟主机?为啥我只是进入 localhost/mamp 文档根目录【英文标题】:Mamp+virtual host? Why am I just getting to localhost/mamp document rootMamp+虚拟主机?为什么我只是进入 localhost/mamp 文档根目录 【发布时间】:2011-05-16 17:07:34 【问题描述】:我正在尝试使用 mamp 设置虚拟主机。当我输入http://resihop:8888 时,我最终进入了 127.0.0.1。为什么?
一些事实:
网站名称: resihop
Apache 端口: 8888
主机数据库:
##
# 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 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 hl2rcv.adobe.com
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 resihop
来自 httpd.conf
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
httpd-vhosts.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:8888
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot "/Users/kristoffernolgren/Documents/Minadokument/hemsidor/resihop"
ServerName resihop
</VirtualHost>
【问题讨论】:
如果是 Apache for Mac 中的错误,您可以尝试使用不同的本地网地址,例如 127.0.0.2。不过应该没有必要。 在我发表评论后马上明白了。 【参考方案1】:您没有指定 NameVirtualHost *:8888 并将您的 VirtualHost 放在该端口上。
NameVirtualHost *:8888
<VirtualHost *:8888>
DocumentRoot "/Users/kristoffernolgren/Documents/Minadokument/hemsidor/resihop"
ServerName resihop
</VirtualHost>
然后检查您的设置:
root@intrepid:~# apache2 -t -S
apache2: bad user name $APACHE_RUN_USER
root@intrepid:~# APACHE_RUN_USER=www-data APACHE_RUN_GROUP=www-data apache2 -t -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server localhost (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost unternet.local (/etc/apache2/sites-enabled/01-unternet:1)
Syntax OK
【讨论】:
您在更改后重新启动了 Apache?你用 apache2 -t -S 检查了吗? 是的,重启就是问题!以上是关于Mamp+虚拟主机?为啥我只是进入 localhost/mamp 文档根目录的主要内容,如果未能解决你的问题,请参考以下文章