简体   繁体   中英

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

WampServer Virtual Hosts

Here's the config file - 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>

Host's file - C:\Windows\System32\drivers\etc

127.0.0.1 localhost
::1 localhost

I can access my project's fine, it's just on the homepage it's bringing this error.

at your Host's file - C:\Windows\System32\drivers\etc, you can add or edit your first line:

127.0.0.1 localhost:7979

There is a process for adding port numbers to WAMPServer.

Using the wampmanager.exe icon in the system tray do the following

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

在此处输入图像描述

This will throw a little dialog onto the screen, enter the port number you want to use, and that will be added to the httpd.conf file like this

Define MYPORT8082 8082

Into this section of the httpd.conf file

Like this

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}

If you add your port number like that, then change the httpd-vhosts.conf file to use the define on the VirtualHosts definition

<VirtualHost *:${MYPORT8082}>

Windows 主机文件

Looks like the port number had to been included like the image above on the hosts file, no error messages now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM