Answer the question
In order to leave comments, you need to log in
Why is /etc/hosts ignored by wsl (ubuntu on windows)?
Good afternoon!
Installed a LAMP server on Subsystem for Linux (WSL) (Ubuntu bash is built into windows 10)
Everything is fine, mysql, ftpd and apache are running.
The test default address with apache hello localhost also starts.
BUT
Adding hosts has no effect.
For example test.com
pings to test.com (127.0.0.1).
set the file to 777, edited in nano
Here are the listings:
/etc/hosts
127.0.0.1 localhost
127.0.0.1 DESKTOP-DSMA6HA.localdomain DESKTOP-DSMA6HA
127.0.0.1 example.com
127.0.0.1 test.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
TimeOut 300
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
AcceptFilter http none
Answer the question
In order to leave comments, you need to log in
The solution is to additionally register hosts in the hosts of windows itself:
127.0.0.1 test.com
127.0.0.1 example.com
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question