[英]This site can’t be reached after installing WSL2 and apache2
我將 WSL1 更新為 WSL2 並安裝
ubuntu 20.04、Apache2 和 php8
現在訪問 localhost 將顯示 Apache2 Ubuntu 默認頁面
接下來我在/etc/apache2/sites-available/items.test.conf
上創建一個conf
文件,其中包含
<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 admin@items.test
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
運行sudo a2ensite items.test.conf
和sudo service apache2 reload
。 接下來用管理員用記事本打開host
,並添加127.0.0.1 items.test
在本地訪問站點items.test
給我這個消息
無法訪問此站點
我在這缺少什么,花 24 小時進行調整,但沒有運氣
又挖了幾個小時后,我找到了答案,用這樣的方式更新主機文件:
127.0.0.1 test.tld
::1 test.tld
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.