Debian/Ubuntu修正Apache2主机名不正确

Apache2运行状态中显示主机名不正确,可尝试用此方法进行修复。


创建conf文件:

vi /etc/apache2/conf-available/server-name.conf 

输入主机名:

ServerName domainname

开启配置文件:

a2enconf server-name

重新加载Apache配置文件:

service apache2 reload

更改Debian/Ubuntu主机名:

vi /etc/hostname

输入主机名:

domainname

 主机名修改后重启后生效


重启Apache:

service apache2 restart

检查错误是否消失:

systemctl -l status apache2.service

如错误仍然存在,请尝试其他方法。