我正在尝试重新启动 Apache 2:
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)
但得到以下错误:
* Restarting web server apache2
AH00558: 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
Run Code Online (Sandbox Code Playgroud)
我试图改变
sudo gedit /etc/apache2/httpd.conf
Run Code Online (Sandbox Code Playgroud)
出现一个空白文件,我添加了这个:
ServerName localhost
Run Code Online (Sandbox Code Playgroud)
但是那个错误并没有消失!
我该如何解决这个问题?
Mei*_*jes 111
我发现了这个:无法确定域名时如何重新启动/重新加载Apache?
好消息!Apache 正在成功重新启动。Apache 只是不确定您想要从哪里提供服务,因此它默认选择您的本地主机 (127.0.0.1)。为防止出现此消息,请通过在
/etc/apache2/apache2.conf文件中添加以下行来说明您希望从 localhost (127.0.0.1) 提供服务:Run Code Online (Sandbox Code Playgroud)ServerName localhost
Ste*_*ler 35
ServerName localhost在虚拟主机部分之外的配置文件中指定是执行此操作的方法。
其他答案建议您应该修改/etc/apache2/httpd.conf. 当 apache 从 apt 升级时,这个文件会被覆盖。对于不想被覆盖的 Apache 配置,您应该创建一个新文件。这是进行此配置更改的“Debian方式”:
# create the configuration file in the "available" section
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf
# enable it by creating a symlink to it from the "enabled" section
sudo a2enconf servername
# restart the server
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)
小智 5
您的本地主机 IP 地址应该是 127.0.0.1,而不是 127.0.1.1。请/etc/hosts正确设置您的文件。然后编辑httpd.conf文件:
sudo -H gedit /etc/apache2/httpd.conf
Run Code Online (Sandbox Code Playgroud)
当出现空白文件时,请添加这一行,然后保存:
ServerName localhost
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
324346 次 |
| 最近记录: |