在wamp服务器中创建vhost

时间:2014-04-25 16:15:09

标签: wamp

的httpd.conf:

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

的httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin admin@localhost
    ServerName localhost
    DocumentRoot "C:/wamp/www/"
    ErrorLog "logs/error.log"
    CustomLog "logs/error-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin shop@angels
    ServerName shop.angels
    ServerAlias www.shop.angels
    DocumentRoot "C:\wamp\www\magento"
    ErrorLog "logs/ag-error.log"
    CustomLog "logs/ag-error-access.log" common
    <Directory /wamp/www/magento>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

文件主持人:

127.0.0.1       localhost
127.0.0.1       shop.angels

但是当我访问shop.angels时,它会重定向到localhost / magento(默认网址),错误是什么?

2 个答案:

答案 0 :(得分:0)

一切看起来都不错,但你可以尝试更改这几行

DocumentRoot "C:\wamp\www\magento"

DocumentRoot "C:/wamp/www/magento"

<Directory /wamp/www/magento>

<Directory "c:/wamp/www/magento">

下一步只是为了消除您以后获得IPV4 / IPV6 ipaddress问题的可能性

Allow from 127.0.0.1

Allow from 127.0.0.1 localhost ::1

或者如果您正在使用Apache V2.4.x更改

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

Require local

你没有提到你正在使用的WAMPServer或Apache的版本,如果这最后一次更改导致Apache错误,即::1 ip地址,那么你使用的是一个尚未理解IPV6的apache,所以你可以离开::1地址。

答案 1 :(得分:0)

如果您已正确配置vhost,则删除文件夹 var / cache ,然后删除F5

我的httpd-vhosts.conf

<VirtualHost *:80>
     DocumentRoot "c:/wamp64/www/sgtest"
     ServerName sgtest.local.cz
     <Directory  "c:/wamp64/www/sgtest">
        AllowOverride All
        Require local
        Allow from all
     </Directory>
</VirtualHost>