0

我是一名开发人员,我通常在我的 PC 上一次开发多个 Web 应用程序。我有 Vista 和 XAMPP。如何在我的 PC 上同时拥有多个“本地主机”?

4

1 回答 1

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

您可能需要在管理员模式下使用文本编辑器打开主机文件以保存更改。

并在您进行更改后关闭并重新启动 Apache 以使其生效。

于 2012-12-14T18:42:15.103 回答