domain 為 myname.com 設定Apache2 conf檔

若要將你的域名(例如:myname.com)連接到在Ubuntu上安裝的WordPress網站,你需要做幾件事情:

  1. 建立 DNS 記錄:
    進入你的域名註冊商(例如:GoDaddy、Namecheap等)的帳戶並進入 DNS 設定頁面。然後:

新增A記錄(如果你的主機IP為xxx.xxx.xxx.xxx):

主機名(Host):@
目標(Points to):伺服器的IP地址(例如:xxx.xxx.xxx.xxx)
或者,新增CNAME記錄(如果你有主機提供商指定的主機名稱):

主機名(Host):@
目標(Points to):你主機提供商提供的主機名稱

  1. 配置虛擬主機(Apache):
    在Ubuntu上設置Apache,讓它知道如何處理這個域名。

在 /etc/apache2/sites-available/ 目錄下,建立一個新的虛擬主機設定檔案(例如 myname.com.conf)。

在這個設定檔中添加類似以下內容的設定:

apache

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.com
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/html/wordpress

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

    <Directory /var/www/html/wordpress>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

啟用新的虛擬主機設定檔:

sudo a2ensite myname.com.conf


重新啟動 Apache 伺服器:

sudo systemctl restart apache2
  1. WordPress 設定:
    登入你的WordPress後台(http://myname.com/wp-admin)。
    在「設定」 > 「一般」中,確保WordPress地址和站點地址是你的域名(http://myname.com)。
    完成這些步驟後,你的域名就應該能夠連接到你在Ubuntu上架設的WordPress網站了。
瀏覽次數:4