首页 > 解决方案 > 无法使用 wamp server 3.1.0 运行虚拟主机网站演示

问题描述

我在我的 PC 中使用 Windows 10 设置了 wamp 服务器。Wamp 启动正常。我运行链接本地主机好。

我创建了一个虚拟主机abcd.test 成功但是它不能运行。

我检查了 apache_error 日志:

[Sat Aug 04 21:52:05.462895 2018] [mpm_winnt:notice] [pid 13960:tid 628] AH00422: Parent: Received shutdown signal -- Shutting down the server. 
[Sat Aug 04 21:52:07.465001 2018] [mpm_winnt:notice] [pid 12684:tid 700] AH00364: Child: All worker threads have exited. 
[Sat Aug 04 21:52:07.489996 2018] [mpm_winnt:notice] [pid 13960:tid 628] AH00430: Parent: Child process 12684 exited successfully. 
[Sat Aug 04 21:52:08.278895 2018] [mpm_winnt:notice] [pid 16620:tid 752] AH00455: Apache/2.4.27 (Win64) PHP/5.6.31 configured -- resuming normal operations 
[Sat Aug 04 21:52:08.278895 2018] [mpm_winnt:notice] [pid 16620:tid 752] AH00456: Apache Lounge VC15 Server built: Jul  7 2017 12:46:00 
[Sat Aug 04 21:52:08.278895 2018] [core:notice] [pid 16620:tid 752] AH00094: Command line: 'D:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d D:/wamp64/bin/apache/apache2.4.27' 
[Sat Aug 04 21:52:08.282891 2018] [mpm_winnt:notice] [pid 16620:tid 752] AH00418: Parent: Created child process 17360 
[Sat Aug 04 21:52:08.564039 2018] [mpm_winnt:notice] [pid 17360:tid 728] AH00354: Child: Starting 64 worker threads.

我运行 cmd 命令行:

'D:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d D:/wamp64/bin/apache/apache2.4.27'*

在此处输入图像描述

文件 httpd:

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80
...

文件虚拟主机:

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName wordpress.test
    DocumentRoot "d:/projects/wordpress"
    <Directory  "d:/projects/wordpress/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

请帮我!

标签: apachelocalhostwampwampserver

解决方案


问题在于你的Listen陈述。您只能有 1Listen对 1 端口。

第一个告诉 Apache 绑定端口 80,第二个告诉它同样的事情,因此冲突。见https://httpd.apache.org/docs/2.4/bind.html

如果你把

Listen 80

它将在所有接口上绑定端口 80 ,因此无需为 IPv4 指定一次,为 IPv6 指定一次。它会自动处理两者。


推荐阅读