在启用httpd-vhosts.conf之后,WAMP服务器没有运行

时间:2021-04-19 16:56:43

I tried enabling Virtual Host on my WAMP installation, but WAMP server will not run if I enable http-vhosts.conf, and the icon remains orange.

我尝试在WAMP安装上启用虚拟主机,但是如果启用http-vhosts, WAMP服务器将不会运行。conf,图标保持橙色。

Here is my hosts file:

这是我的主机文件:

127.0.0.1       localhost
127.0.0.1       test.localhost

My httpd.conf:

我的httpd . conf。

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

and my httpd-vhosts.conf:

和我httpd-vhosts.conf:

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

It works fine if I add the VirtualHosts to my httpd.conf, but I noticed that the Apache server will not run if I comment out "Include conf/extra/httpd-vhosts.conf". What is causing this issue?

如果我将虚拟主机添加到我的httpd中,它可以正常工作。但是我注意到,如果我注释掉“包含conf/extra/httpd-vhosts.conf”,Apache服务器将不会运行。是什么引起了这个问题?

Thanks,

谢谢,

3 个解决方案

#1


17  

To anyone who finds this stack.

给任何找到这个堆栈的人。

  1. Go to start menu ->
  2. 转到开始菜单->
  3. type "cmd" ->
  4. 输入“cmd”- >
  5. press enter ->
  6. 按enter键- >
  7. paste the following "C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe"
  8. 粘贴下面的“C:\ wamp \ bin \ apache \ apache2.2.22 \ bin \ httpd.exe”

This will indicate to you the exact line on which the error is occurring.

这将向您指出发生错误的确切行。

Note: You may need to tweak the path according your the version of Apache you are using.

注意:您可能需要根据使用的Apache版本调整路径。

#2


11  

OK I feel this my duty to put this...

好吧,我觉得我有责任这么说……

I too went on a rampage of checking forms and doing things like

我也疯狂地检查表格和做类似的事情

Listen *:80 & NameVirtualHost *:80 but found that this was not necessary, the default settings were fine for me.

听录音*:80 & NameVirtualHost *:80,但是发现这不是必需的,默认设置对我来说没有问题。

the problem started when I tried to put in my vhost declaration

当我试图输入vhost声明时,问题就出现了

<VirtualHost 127.0.0.1>
    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
    ServerName media.weber.dev
    <Directory 'c:\wamp\www\media_weber_edu\public'>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
    <\Directory>
</VirtualHost>

here lied the problem

在这里撒谎这个问题

<\Directory> vs </Directory>

< \目录>和< /目录>

A huge help to finding this was running C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

找到它的一个巨大帮助是运行C: wamp\bin\ apache2.22 \bin\ bin\httpd.exe

this gave me an error like this

这给了我一个像这样的错误

httpd.exe: Syntax error on line 469 of C:/wamp/bin/apache/apache2.2.22/conf/httpd.conf: Syntax error on line 42 of C:/wamp/bin/apache/apache2.2.22/conf/extra/httpd-vhosts.conf: Expected </\\Directory> but saw </VirtualHost>

So this may not be the exact problem but I hope this will help those in the future. So take a deep breath... glue the hair back on your head... its going to be ok :)

所以这可能不是确切的问题,但我希望这将在未来帮助那些人。所以深呼吸……把头发粘在头上……一切都会好起来的

#3


0  

You just need to change it like as this: everything will be OK.

你只需要像这样改变:一切都会好起来的。

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

If somebody has error of Directory, he may need to modify it like below:

如果有人有目录错误,他可能需要修改如下:

<VirtualHost 127.0.0.1>
#    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
     ServerName media.weber.dev
#    <Directory 'c:\wamp\www\media_weber_edu\public'>
#        Options Indexes FollowSymLinks MultiViews
#       AllowOverride all
#    <\Directory>
</VirtualHost>

notes: Apache does not allow multiple <Directory> arguments!

注意:Apache不允许有多个 <目录> 参数!

在启用httpd-vhosts.conf之后,WAMP服务器没有运行

#1


17  

To anyone who finds this stack.

给任何找到这个堆栈的人。

  1. Go to start menu ->
  2. 转到开始菜单->
  3. type "cmd" ->
  4. 输入“cmd”- >
  5. press enter ->
  6. 按enter键- >
  7. paste the following "C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe"
  8. 粘贴下面的“C:\ wamp \ bin \ apache \ apache2.2.22 \ bin \ httpd.exe”

This will indicate to you the exact line on which the error is occurring.

这将向您指出发生错误的确切行。

Note: You may need to tweak the path according your the version of Apache you are using.

注意:您可能需要根据使用的Apache版本调整路径。

#2


11  

OK I feel this my duty to put this...

好吧,我觉得我有责任这么说……

I too went on a rampage of checking forms and doing things like

我也疯狂地检查表格和做类似的事情

Listen *:80 & NameVirtualHost *:80 but found that this was not necessary, the default settings were fine for me.

听录音*:80 & NameVirtualHost *:80,但是发现这不是必需的,默认设置对我来说没有问题。

the problem started when I tried to put in my vhost declaration

当我试图输入vhost声明时,问题就出现了

<VirtualHost 127.0.0.1>
    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
    ServerName media.weber.dev
    <Directory 'c:\wamp\www\media_weber_edu\public'>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
    <\Directory>
</VirtualHost>

here lied the problem

在这里撒谎这个问题

<\Directory> vs </Directory>

< \目录>和< /目录>

A huge help to finding this was running C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

找到它的一个巨大帮助是运行C: wamp\bin\ apache2.22 \bin\ bin\httpd.exe

this gave me an error like this

这给了我一个像这样的错误

httpd.exe: Syntax error on line 469 of C:/wamp/bin/apache/apache2.2.22/conf/httpd.conf: Syntax error on line 42 of C:/wamp/bin/apache/apache2.2.22/conf/extra/httpd-vhosts.conf: Expected </\\Directory> but saw </VirtualHost>

So this may not be the exact problem but I hope this will help those in the future. So take a deep breath... glue the hair back on your head... its going to be ok :)

所以这可能不是确切的问题,但我希望这将在未来帮助那些人。所以深呼吸……把头发粘在头上……一切都会好起来的

#3


0  

You just need to change it like as this: everything will be OK.

你只需要像这样改变:一切都会好起来的。

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

If somebody has error of Directory, he may need to modify it like below:

如果有人有目录错误,他可能需要修改如下:

<VirtualHost 127.0.0.1>
#    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
     ServerName media.weber.dev
#    <Directory 'c:\wamp\www\media_weber_edu\public'>
#        Options Indexes FollowSymLinks MultiViews
#       AllowOverride all
#    <\Directory>
</VirtualHost>

notes: Apache does not allow multiple <Directory> arguments!

注意:Apache不允许有多个 <目录> 参数!

在启用httpd-vhosts.conf之后,WAMP服务器没有运行