我是开发人员,我通常在PC上开发多个Web应用程序。我有Vista和XAMPP。如何在我的电脑上同时拥有多个“本地主机”?
答案 0 :(得分:0)
Apache支持基于名称的虚拟主机来托管多个站点。您需要为每个站点在两个文件中创建条目。例如,使用XAMPP 1.8.1和Vista,如果你想使用常规localhost和Zend 2框架单独开发:
在C:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf
中##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host.localhost
##DocumentRoot "C:/xampp/htdocs/dummy-host.localhost"
##ServerName dummy-host.localhost
##ServerAlias www.dummy-host.localhost
##ErrorLog "logs/dummy-host.localhost-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
##</VirtualHost>
##add these two entries
<VirtualHost *:80>
DocumentRoot "[path to]/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot [path to]\xampp\htdocs\zf2-tutorial\public
SetEnv APPLICATION_ENV "development"
<Directory [path to]\xampp\htdocs\zf2-tutorial\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
在C:\ Windows \ System32 \ drivers \ etc \ hosts
中# For example:
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
#add two entries where name matches ServerName in httpd-vhosts.conf
127.0.0.1 localhost
127.0.0.1 zf2-tutorial.localhost
您可能需要在管理员模式下使用文本编辑器打开hosts文件以保存更改。
在进行更改后关闭并重新启动Apache,以使它们生效。