2014-11-05 183 views
0

我已经构式WAMP-Server,以便它会与一些地方领域的工作,如下: http://proloma http://sweporrWAMP服务器多个域

它的工作原理很好当地使用,但我有2个不同的.com域名指向我的服务器,我怎么能做到这一点,使互联网上的人可以通过访问不同的域访问不同的页面?
我的域名是:
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 [email protected] 
    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 [email protected] 
    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 [email protected] 
    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> 

这是我的主人:

# 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 

而且我按照所有这些步骤: https://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp

回答

0

我自己修复了!
我只是错过了部分放
ServerAlias * .proloma.com proloma.com
ServerAlias * .sweporr.com sweporr.com而不是

只是
ServerAlias www.proloma.com

,因为如果我输入www而不是如果我只输入网址等,唯一的WWW情况将只针对正确的服务器。

0

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

它检查ServerNameServerAlias参数以找到正确的虚拟主机。因此,您只需更改ServerName参数即可使用正确的.com tld。

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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 [email protected] 
    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> 

您不需要更改HOSTS文件以使其适用于外部互联网使用,因为这仅影响本地访问。

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