如何在Windows上为多个域名设置虚拟主机? 我将把它用于我自己的testing项目。 我有3个项目,我需要安装,目前我正在使用xampplite的便携式阿帕奇。
我还需要访问另一个项目,但它就像inputhttp:// localhost / my-project /
如何编写虚拟主机configuration?
你需要做几个步骤才能完成这项工作。
1.)更新hosts
文件。 在Windows XP上,您可以在c:\WINDOWS\system32\drivers\etc\
下找到它。 你应该已经看到从下面的第一行,它会照顾你提到的其他项目。 – 添加额外的请求到所提到的虚拟主机路由回你自己的机器。
127.0.0.1 localhost 127.0.0.1 foo-bar.com 127.0.0.1 abcdef.com 127.0.0.1 qwerty.com
2.)在Apache配置中更新vhosts文件。 在您的XAMPP文件夹下,将以下内容添加到apache\conf\extra\httpd-vhosts.conf
,如果需要更改端口(即如果使用8080而不是端口80)。
<VirtualHost *:80> DocumentRoot C:/xampplite/htdocs/foo-bar/ serverName www.foo-bar.com </VirtualHost> <VirtualHost *:80> DocumentRoot C:/xampplite/htdocs/abcdef/ serverName www.abcdef.com </VirtualHost> <VirtualHost *:80> DocumentRoot C:/xampplite/htdocs/qwerty/web/ serverName www.qwerty.com </VirtualHost>
3.)做一个快速的配置检查。 打开{XAMPP-folder}\apache\conf\httpd.conf
文件,并确保以下部分没有被前面的#
字符注释掉:
Include conf/extra/httpd-vhosts.conf
4.)重新启动XAMPP。
…现在你应该全部设置。 如果你把它放在C:/xampplite/htdocs/my-project/
你的其他项目应该可以在你提到的URI中访问。
为了获得C:/xampp/htdocs/my-project/
working,我必须将以下(默认?)VirtualHost添加到apache\conf\extra\httpd-vhosts.conf
(在MicE教程的第2步中)。
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" serverName localhost </VirtualHost>