Mamp+虚拟主机?为什么我只是进入 localhost/mamp 文档根目录

发布于 2024-10-04 17:18:16 字数 2347 浏览 4 评论 0原文

我正在尝试使用 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>

I'm trying to set up a virtual host using mamp. When i enter http://resihop:8888 I end up in 127.0.0.1. Why?

Some facts:

Sitename: resihop

Apache port: 8888

Host database:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-10-11 17:18:16

您没有指定 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

You didn't specify NameVirtualHost *:8888 and put your VirtualHost on that port.


NameVirtualHost *:8888

<VirtualHost *:8888>
   DocumentRoot "/Users/kristoffernolgren/Documents/Minadokument/hemsidor/resihop"
   ServerName resihop
</VirtualHost>

Then check your setup:


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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文