[英]Multiple domains on one Apache server(WAMP)
I have got one IP address on my sv, and I want to set up two domains on one Apache Server with another DocumentRoot. 我的sv上有一个IP地址,我想在一个Apache服务器上用另一个DocumentRoot设置两个域。 Here is wat I got in httpd-vhosts.conf
这是我在httpd-vhosts.conf中获得的wat
<VirtualHost *:80>
DocumentRoot "C:\wamp\www\mail"
ServerName mail.A.pl
</VirtualHost>
<VirtualHost *:80>
ServerName B.eu
DocumentRoot "c:\wamp\www\B"
</VirtualHost>
<VirtualHost *:80>
ServerName A.pl
DocumentRoot "c:\wamp\www"
</VirtualHost>
Even when I try to load page: http://www.A.pl
or www.B.eu
or B.eu
or A.pl
it loads mail.A.pl
. 即使我尝试加载页面:
http://www.A.pl
: www.B.eu
或B.eu
或A.pl
或A.pl
它mail.A.pl
加载mail.A.pl
What am I doing wrong? 我究竟做错了什么?
EDITED EDITED
Here is new httpd-vhost, now it loads correct pages, but fe for A.pl doesn't show any images, and on mail.A.pl doesn't want to send POST data: 这是新的httpd-vhost,现在它加载正确的页面,但是A.pl的fe不显示任何图像,并且在mail.A.pl上不想发送POST数据:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\wamp\www\mail"
ServerAlias mail.A.pl
ServerName mail.A.pl
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName B.eu
ServerAlias *.B.eu
DocumentRoot "c:\wamp\www\B"
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName A.pl
ServerAlias A.pl
DocumentRoot "c:\wamp\www"
</VirtualHost>
EDIT2 Thank you both for help. EDIT2谢谢你们的帮助。
I just switched first VirtualHost with last and it mistery started working :O 我刚刚将第一个虚拟主机切换到最后,它开始工作:O
You need to map NameVirtualHost
to the IP address 127.0.0.1 for mapping multiple virtual host. 您需要将
NameVirtualHost
映射到IP地址127.0.0.1以映射多个虚拟主机。
For example: 例如:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot 'C:\wamp\www'
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName myclient.local
DocumentRoot 'C:\wamp\www\ClientsMyClient'
</VirtualHost>
There are a few things that you need to have I think. 我想你需要做一些事情。
1) Uncomment the Virtual hosts line in Apache's config file so it includes httpd-vhosts.conf
. 1)取消注释Apache配置文件中的虚拟主机行,使其包含
httpd-vhosts.conf
。 On OSX that is: 在OSX上:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
2) Put the necessary lines in your hosts file ( http://en.wikipedia.org/wiki/Hosts_(file ) ): 2)在主机文件中放置必要的行( http://en.wikipedia.org/wiki/Hosts_(file )):
127.0.0.1 mail.A.pl
127.0.0.1 A.pl
127.0.0.1 B.pl
127.0.0.1 every.A.pl
127.0.0.1 subdomain.A.pl
127.0.0.1 needs-a-line.A.pl
The ServerAlias
can go actually, you don't need that for subdomains, only for similar "main" domains. 实际上,
ServerAlias
可以实现,对于子域,您不需要这样,仅适用于类似的“主”域。
Your httpd-vhosts.conf
file is fine. 您的
httpd-vhosts.conf
文件没问题。
Why the images and POSTs are not working I don't know. 为什么图像和POST不起作用我不知道。 That doesn't have anything to do with this host file.
这与此主机文件没有任何关系。 Perhaps with another
.htaccess
file. 也许与另一个
.htaccess
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.