Fil
Fil

Reputation: 8863

This site can’t be reached after installing WSL2 and apache2

I updated my WSL1 to WSL2 and install

ubuntu 20.04, Apache2 and php8

Now visiting localhost will display the Apache2 Ubuntu Default Page

Next I create a conf file on /etc/apache2/sites-available/items.test.conf containing

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName items.test

    ServerAdmin [email protected]
    DocumentRoot /mnt/c/www/path/to/public

    <Directory /mnt/c/www/path/to/public/>
        Options Indexes FollowSymLinks
            AllowOverride All
        Require all granted
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

run sudo a2ensite items.test.conf and sudo service apache2 reload. Next open host with notepad with administrator, and added 127.0.0.1 items.test

Visiting the site locally items.test give me this message

This site can’t be reached

What am I missing in this, spend 24hrs tweaking and no luck

Upvotes: 2

Views: 2324

Answers (1)

Fil
Fil

Reputation: 8863

After digging another few hours I found the answer, update host file with such a like:

127.0.0.1 test.tld
::1 test.tld

Source: https://github.com/microsoft/WSL/issues/4347

Upvotes: 5

Related Questions