[英]Apache2 ServerName and ServerAlias not working
在幾乎全新的 Ubuntu 20.04 LTS 計算機上,我想在我的本地計算機上設置一個虛擬主機。 於是我在/var/www/test/
下創建了一個index.html
,內容如下: you have entered a test page
我在/etc/apache2/sites-available/
下設置了一個test.conf
文件
內容如下:
<VirtualHost *:80>
ServerAdmin webmaster@zhihu.com
DocumentRoot /var/www/test/
ServerName zhihu.com
ServerAlias www.zhihu.com
<Directory /var/www/test/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/hosts
配置可能正在工作,如ping
所示
ping zhihu.com
PING zhihu.com (127.0.1.1) 56(84) bytes of data.
64 bytes from xxx (127.0.1.1): icmp_seq=1 ttl=64 time=0.045 ms
但是瀏覽器無法將我帶到現在應該托管在/var/www/test/
中的域。
我還有a2ensite test.conf
和a2dissite 000-default.conf
和service apache2 reload
所以我認為唯一可能發生錯誤的地方是ServerName
和ServerAlias
。 為什么他們不工作?
您能否使用 a2ensite 啟用 VirtualHost 並以隱身模式訪問站點。
Ensure that the ssl certificate for the site includes both example.com and www.example.com and ServerAlias is set to www.example.com
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.