Wampserver - ServerName localhost:7979 未定义到主机文件中

Wampserver - The ServerName localhost:7979 is not defined into hosts file

WampServer Virtual Hosts

这是配置文件 - C:\wamp64\bin\apache\apache2.4.51\conf\extra\httpd-vhosts.conf

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

主持人的文件 - C:\Windows\System32\drivers\etc

127.0.0.1 localhost
::1 localhost

我可以正常访问我的项目,只是在主页上出现了这个错误。

WAMPServer有添加端口号的进程。

使用系统托盘中的 wampmanager.exe 图标执行以下操作

Right click wampmanager icon -> Tools -> Add a Listen port to Apache

这会在屏幕上弹出一个小对话框,输入您要使用的端口号,然后它将像这样添加到 httpd.conf 文件中

Define MYPORT8082 8082

进入 httpd.conf 文件的这一部分

像这样

Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.52
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
Define MYPORT8082 8082
Define SRVROOT ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}

如果您像那样添加端口号,然后更改 httpd-vhosts.conf 文件以使用 VirtualHosts 定义中的定义

<VirtualHost *:${MYPORT8082}>

在您的主机文件 - C:\Windows\System32\drivers\etc,您可以添加或编辑您的第一行:

127.0.0.1 localhost:7979

看起来端口号必须像上图一样包含在主机文件中,现在没有错误消息。