首页 文章

启用httpd-vhosts.conf后WAMP服务器未运行

提问于
浏览
11

我尝试在我的WAMP安装上启用虚拟主机,但如果启用http-vhosts.conf,则WAMP服务器将无法运行,并且图标仍为橙色 .

这是我的主机文件:

127.0.0.1       localhost
127.0.0.1       test.localhost

我的httpd.conf:

# Virtual hosts
Include conf/extra/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>

如果我将VirtualHosts添加到我的httpd.conf中,它可以正常工作,但我注意到如果我注释掉“Include conf / extra / httpd-vhosts.conf”,Apache服务器将无法运行 . 是什么导致了这个问题?

谢谢,

3 回答

  • 11

    要确定发生错误的确切行,请执行以下步骤:

    • 转到开始菜单

    • 类型"cmd"

    • 按回车键

    • 粘贴以下 C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

    注意:您可能需要根据Apache的本地版本调整路径的apache2.2.22部分 .

  • 18

    好吧,我认为这是我的职责......

    我也经常检查表格和做事情

    Listen *:80NameVirtualHost *:80 但发现这没有必要,默认设置对我来说很好 .

    当我试图输入我的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>
    

    这里撒谎了

    <\Directory> vs </Directory>

    找到这个的巨大帮助正在运行 C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

    这给了我这样的错误

    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>
    

    所以这可能不是确切的问题,但我希望这将有助于未来的人们 . 深吸一口气......将头发粘在头上......它会好的:)

  • 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>
    

    注意:Apache不允许多个 <Directory> 参数!

    multiple  arguments error screenshot:

相关问题