Apache Wamp服务器包含多个域

Apache Wamp服务器包含多个域,apache,dns,wampserver,server,Apache,Dns,Wampserver,Server,我已经对WAMP服务器进行了配置,使其能够与多个本地域协同工作,如下所示: http://proloma http://sweporr 它适合本地使用,但我有两个不同的.com域指向我的服务器,我如何使它能够让internet上的用户通过访问不同的域来访问不同的页面? 我的域名是: www.proloma.com www.sweporr.com 现在它们都指向同一个文件夹c:/wamp/www。 我想让他们这样说: www.proloma.com->http://proloma www.swep

我已经对WAMP服务器进行了配置,使其能够与多个本地域协同工作,如下所示: http://proloma http://sweporr

它适合本地使用,但我有两个不同的.com域指向我的服务器,我如何使它能够让internet上的用户通过访问不同的域来访问不同的页面? 我的域名是: www.proloma.com www.sweporr.com 现在它们都指向同一个文件夹c:/wamp/www。 我想让他们这样说: www.proloma.com->http://proloma www.sweporr.com->http://sweporr

这是我的httpd-vhosts.conf:

# Virtual Hosts
#
# Required modules: mod_log_config

# 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.4/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.

#
# 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>
    ServerAdmin admin@localhost
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ServerAlias www.localhost.com
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin ranama@proloma.com
    DocumentRoot "C:/Users/Proloma/Dropbox/ProlomaDotCom/www"
    ServerName proloma
    <Directory "C:/Users/Proloma/Dropbox/ProlomaDotCom/www">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ServerAlias www.proloma.com
    ErrorLog "logs/proloma-error.log"
    CustomLog "logs/proloma-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin ranama@sweporr.com
    DocumentRoot "C:/Users/Proloma/Dropbox/SwePorrDotCom/www"
    ServerName sweporr
    <Directory "C:/Users/Proloma/Dropbox/SwePorrDotCom/www">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ServerAlias www.sweporr.com
    ErrorLog "logs/sweporr-error.log"
    CustomLog "logs/sweporr-access.log" common
</VirtualHost>
我遵循了所有这些步骤:

对于虚拟主机,Apache基本上会查看传入的url,以决定使用哪个虚拟主机从中服务器页面

它检查ServerName和ServerAlias参数以找到正确的虚拟主机。因此,您需要做的就是更改ServerName参数以使用正确的.com tld

您无需更改HOSTS文件即可使其用于外部internet,因为这只会影响本地访问

当然,您必须对路由器进行端口转发,以便端口80上的外部连接不会被拒绝,并且实际上会被转发到运行Apache的PC的ip地址。 这台电脑当然也应该有一个静态ip地址,否则重新启动后,路由器DHCP服务器可能会给它一个不同的ip地址。

我自己修复了它! 我只是错过了要放的部分 ServerAlias*.proloma.com proloma.com 服务器别名*.sweporr.com sweporr.com

而不仅仅是 ServerAlias www.proloma.com

因为如果我键入www,唯一的www案例将只针对正确的服务器,而不是仅键入url等

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       proloma
127.0.0.1       sweporr
<VirtualHost *:80>
    ServerAdmin ranama@proloma.com
    DocumentRoot "C:/Users/Proloma/Dropbox/ProlomaDotCom/www"
    ServerName proloma.com
    ServerAlias www.proloma.com
    <Directory "C:/Users/Proloma/Dropbox/ProlomaDotCom/www">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "logs/proloma-error.log"
    CustomLog "logs/proloma-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin ranama@sweporr.com
    DocumentRoot "C:/Users/Proloma/Dropbox/SwePorrDotCom/www"
    ServerName sweporr.com
    ServerAlias www.sweporr.com
    <Directory "C:/Users/Proloma/Dropbox/SwePorrDotCom/www">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "logs/sweporr-error.log"
    CustomLog "logs/sweporr-access.log" common
</VirtualHost>