用 Ubuntu 安裝好 Apache 後,啟動 Apache 時會出現以下報錯:
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
出現錯誤的原因是 Apache 不能抓取系統的 hostname, 以下是兩個簡單的解決方法:
1. 在 /etc/apache2/apache2.conf 檔案最後加入 ServerName 設定:
$ echo “ServerName ubuntu.mydomain.com” >> /etc/apache2/apache2.conf
然後重新啟動 Apache 便完成了。
2. 用 hostname 指令設定 host:
$ sudo hostnamectl set-hostname ubuntu.mydomain.com