在一台 wamp 服务器中托管多个站点
我有两个不同的站点,我想通过 wamp 服务器托管它们,例如,我的第一个站点是 http://one。 gov.ae 第二个是 http://two.gov.ae
我想要的是当我输入第一个站点时,它应该打开第一个站点的索引,当我输入第二个站点时,它应该打开索引应该打开第二个站点。
但无论我输入什么,它都会打开第一个索引
,但是我将两者都添加到 httpd-vhosts.con 中,并取消注释 http.conf 中的以下行
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
所以任何人都可以告诉我在这种情况下我可以做什么,
这是我的 httpd-vhosts .conf代码
<VirtualHost 172.20.10.121:80>
# ServerAdmin admin@localhost
DocumentRoot "C:/wamp/www"
ServerName localhost
# ServerAlias www.dummy-host.localhost
# ErrorLog "logs/dummy-host.localhost-error.log"
# CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>
<VirtualHost 172.20.10.121:8080>
# ServerAdmin [email protected]
ServerName meera.am.gov.ae
DocumentRoot "c:wamp/www/meera"
Directoryindex index.php index.html
# ErrorLog "logs/dummy-host2.localhost-error.log"
# CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>
我在httpd文件中注释了以下内容
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
# Order allow,deny
# Deny from all
# Satisfy All
</FilesMatch>
I have two different sites and i want to host both of them through wamp server for example, my first site is http://one.gov.ae and the second one is http://two.gov.ae
what I want is when I type the first site it should open the index for the first one and i when i type the second one it should open the second site.
but whatever I type it open the index for the first one
however I add both sits in httpd-vhosts.con and uncomment the following line in http.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
So anyone can tell me what I can do in such situation
here is my httpd-vhosts.conf code
<VirtualHost 172.20.10.121:80>
# ServerAdmin admin@localhost
DocumentRoot "C:/wamp/www"
ServerName localhost
# ServerAlias www.dummy-host.localhost
# ErrorLog "logs/dummy-host.localhost-error.log"
# CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>
<VirtualHost 172.20.10.121:8080>
# ServerAdmin [email protected]
ServerName meera.am.gov.ae
DocumentRoot "c:wamp/www/meera"
Directoryindex index.php index.html
# ErrorLog "logs/dummy-host2.localhost-error.log"
# CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>
I comment the following in httpd file
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
# Order allow,deny
# Deny from all
# Satisfy All
</FilesMatch>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
所以我猜你的服务器也会侦听端口 8080。你没有提到那部分。
问题可能是您还启用了基于名称的虚拟主机,例如:
... 或
这样 Apache 通过主机名(
Host
请求标头)来识别主机。如果没有发送主机或在配置中找不到匹配的ServerName
,则第一个主机(默认主机)将处理该请求。尽管我强烈建议您使用基于名称的虚拟主机,而不是这种疯狂的端口。使用诸如
mysite.test
或jopbsite.test
或projectname.test
等名称。这样它们都可以监听端口 80,你必须为所有主机定义ServerName
,使用我上面的示例之一启用基于名称的虚拟主机,然后在以下文件中定义您的 NS 条目:
编辑:
你的 vhosts.conf 中应该有类似这样的内容:
So I guess your server does listen on the port 8080 too. You did not mention that part.
The problem could be that you also enabbled name based virtual hosting with something like:
... or
This way Apache is identifying hosts by hostname (the
Host
request header). If no host is sent or no matchingServerName
found in config, the first host (the default host) will handle the request.Although instead of this port madness I strongly recommend you using name-based virtual hosts. With names like
mysite.test
orjopbsite.test
orprojectname.test
etc. This way they can all listen on port 80, you have to define theServerName
for all of the hosts, enbale name based virtual hosting with one of my examples above then define your NS entries in:file.
Edit:
ou should have something like this in your vhosts.conf:
有很多这方面的详细教程。我有一段时间没有使用 WAMP,但这是我上次使用时使用的指南: http://cesaric .com/?p=255
There are lots of detailed tutorials on this. I haven't used WAMP in a while but this is the guide I used when I did last: http://cesaric.com/?p=255
您需要修改 .conf 以适应两个单独的虚拟主机。
在下面的示例中,您基本上需要设置 ServerName、ServerAlias 和其他变量才能将它们分开。
希望有帮助。请务必在修改 .conf 文件之前停止 Apache,然后再次启动它。
You'll need to modify your .conf to account for two separate virtual hosts.
In the below example you'll basically need to set the ServerName, ServerAlias and other variables in order to separate them.
Hope that helps. Be sure to stop Apache before modifying the .conf file and then start it again.
不久前我遇到了这个问题,我发现这是一个愚蠢的错误,我没有在 httpd 服务器上重新启动。
如果您的
PATH
中链接了/bin
目录,您可以尝试从命令提示符运行此命令:希望它有帮助!干杯:)
I had this problem a while back and I found out that it was a silly mistake that I didn't do a restart on the httpd server.
You could try running this from a command prompt if you have the
/bin
directory linked in yourPATH
:Hope it helps ! Cheers :)