我正在尝试使用mamp设置虚拟主机。当我输入http://resihop:8888时,我最终进入127.0.0.1。为什么呢?
一些事实:
Sitename: 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>
答案 0 :(得分:5)
您没有指定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