用 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