虚拟主机上的服务器名不工作


Server name on virtual host not working

我需要你的帮助。我正在做一个zend框架2项目,这个项目的名字在Wamp/www文件夹是pizza。我尝试在hosts文件httpd.conf和httpd-vhosts.conf上配置一个虚拟主机,以与这个项目url: pizza一起工作。本地/

localhost:8080/pizza/public/

,但我的配置是不正确的。注意,我使用的是localhost:8080,而不是localhost。

请帮我找出我做错了什么。这是我的文件:

httpd . conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

httpd-vhosts.conf:

<VirtualHost *:8080>
    ServerAdmin webmaster@localhost.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias www.localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:8080>
    DocumentRoot "c:/wamp/www/pizza/public"
    ServerName pizza.local
    <Directory "c:/wamp/www/pizza/public">
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

主机文件:

# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
127.0.0.1       localhost
127.0.0.1   pizza.local
127.0.0.1       localhost

当您在端口8080上使用这个VHOST时。您需要在URL中注明如下。

http://pizza.local:8080/