2012-03-22 145 views
3

我正在使用Wamp 2.2编辑conf/extra/httpd-vhosts.conf编辑此文件来添加VirtualHosts,但是当我在httpd.conf的未注释行中包含httpd-vhosts.conf文件后,重新启动Wamp后无法启动。如果我恢复更改是正常工作。虚拟主机与WAMP

任何想法为什么会发生这种情况?

这是我使用的代码httpd-vhost.conf

<VirtualHost *> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/wamp/www" # change this line with your htdocs folder 
    ServerName localhost 
    ServerAlias localhost 
    <Directory "C:/wamp/www"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

# WooCommerce Multisite 
<VirtualHost dev.lo> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/wamp/www/dev" 
    ServerName dev.lo 
    ServerAlias dev.lo 
    <Directory "C:/wamp/www/dev"> 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

感谢

乔治

编辑

由于安德烈亚斯·哈根的建议,我通过httpd的运行Apache 。可执行程序。

第一个错误是DocumentRoot的错误参数,因为出现的注释类似于作为第二个参数,当DocumentRoot只接受一个时。

然后我得到警告:[warn] NameVirtualHost *:80 has no VirtualHosts。有一个快速搜索,发现非常有帮助的问题 - https://serverfault.com/questions/1405/apache-2-startup-warning-namevirtualhost-80-has-no-virtualhosts

回答

5

可能在vhosts文件中有一些不好的配置。尝试从命令行启动apache,以便获取错误输出。这将帮助您识别您的问题。

+0

什么是从cmd开始它的命令? – Mamaduka 2012-03-22 10:03:34

+0

只需运行该exe文件。认为它被命名为httpd.exe – 2012-03-22 10:05:50

+0

试过,但httpd.exe只要我打开它就关闭,所以不能得到错误通知。 – Mamaduka 2012-03-22 15:55:13

3

打开您的主机文件(\WINDOWS\system32\drivers\etc\hosts)。 此行添加到底层:

127.0.0.1  test 

这会告诉您的计算机中包含测试任何URL将被路由到127.0.0.1(本地主机)。

现在打开httpd.conf这添加到文件的最底部:

NameVirtualHost *:80 
<VirtualHost *:80> 
    DocumentRoot "c:/wamp/www/myfirstsite/" 
    ServerName testsite 
</VirtualHost> 

现在重启apache,并导航到:http://test/(您可能需要重新启动浏览器,以使更改生效)

希望这能奏效。

+0

我已经编辑了dev.lo的主机文件 - “127.0.0.1 dev.lo”。 – Mamaduka 2012-03-22 10:03:46

0

转到C:/驱动器,然后选择文件夹WAMP

,并转到C:\ WAMP \ BIN \ apache的\ Apache2.4.4 \ conf以选择httpd.conf文件。

编辑用记事本和去58行号

变化收听80和替换听8181保存文件并重新启动Apache服务器

现在检查URL,例如像这样的本地主机:8181

我有使用这一跳你将会成功。