簡體   English   中英

虛擬主機 UBUNTU 顯示無法訪問此站點

[英]Vistual host UBUNTU shows This site can’t be reached

我已經在 Ubuntu 20.04.3 LTS 上配置了虛擬主機,但它不起作用。

首先使用以下方法創建目錄:

sudo mkdir -p /var/www/domain1.com/public_html

然后在其中創建 index.html 文件:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Welcome to domain1.com</title>
  </head>
  <body>
    <h1>Success! domain1.com home page!</h1>
  </body>
</html>

為了避免權限問題,我運行了這個命令:

sudo chown -R www-data: /var/www/domain1.com

然后在 /etc/apache2/sites-available 我創建了一個配置文件:

/etc/apache2/sites-available/domain1.com.conf

並將這段代碼放入其中

<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias www.domain1.com
    ServerAdmin webmaster@domain1.com
    DocumentRoot /var/www/domain1.com/public_html

    <Directory /var/www/domain1.com/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/domain1.com-error.log
    CustomLog ${APACHE_LOG_DIR}/domain1.com-access.log combined
</VirtualHost>

然后運行這個命令:

sudo a2ensite domain1.com

然后使用命令重新啟動 apache:

sudo systemctl restart apache2

然后測試配置:

sudo apachectl configtest

並得到 output 作為語法 OK

但是當我在瀏覽器中訪問 domain1.com 時, "This site can't be reached"錯誤。

您已將 Apache 配置為特殊情況下它收到的domain1.com的任何請求

你沒有:

  • 注冊域1.com
  • 在 IP 地址上配置了一個 DNS 服務器,其 A 記錄指向 domain1.com,ZE9713AE04A02A810D94F33 正在監聽

(或者使用類似hosts文件的東西進行本地破解)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM