2012-02-25 754 views
7

当我尝试重新启动Apache issueing /etc/init.d/apache2重新启动,我得到了以下信息:如何设置服务器的完全限定域名?

[email protected]:~# /etc/init.d/apache2 restart 
* Restarting web server apache2                                apache2: apr_sockaddr_info_get() failed for server 
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 
... waiting apache2: apr_sockaddr_info_get() failed for server 
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 
                                         [ OK ] 
[email protected]:~# cat /etc/hostname 
iSell 
[email protected]:~# hostname 
server 
[email protected]:~# hostname -f 
hostname: Name or service not known 
[email protected]:~# cat /etc/hosts 
127.0.0.1  localhost localhost.localdomain 
108.1.*.*  eins 
[email protected]:~# 

注:这两个星号的IP在/ etc年底/主机是由我添加在发布时。 注2:假设我的域名是www.xyz.net

我想确切地知道我必须一步一步来做。 非常感谢!

+3

这不是编程相关的。请考虑在其他SE网站上发帖。 – jurgemaister 2012-05-21 07:46:31

+0

此行为仅在ubuntu – 2012-08-30 14:17:09

回答

21

只要编辑空白httpd.conf中的Apache下列要求:

sudo gedit /etc/apache2/httpd.conf 

添加一行:

ServerName localhost 

保存并退出并重新启动Apache:

sudo /etc/init.d/apache2 restart 

那将照顾它。

+0

为我工作谢谢 – 2014-06-30 10:33:46

+0

感谢您也为我工作! – 2015-10-26 18:17:17

+0

关于Jessie修复/etc/apache2/apache2.conf – fcm 2016-04-27 02:21:34

0

编辑您的hosts文件

sudo nano /etc/hosts 

看,如果你的ip 127.0.1.1作为服务器

127.0.1.1  srv-web-01 

,并重新启动的好名字你的Apache

sudo service apache2 restart 
+0

apache2不够 – fcm 2016-04-27 02:20:17

1

1)编辑文件: vi /etc/apache2/apache.conf 2)写在最后一行(t o看你的机器名写:cat/etc/hostname): ServerName你的机器名称 3)service apache2 reload

enjoyit!

1
  1. 首先,检查你的Apache的版本
    $ apache2 -v
  2. 如果你的Apache版本2.x中,使用下面的命令来避免此消息
    $ echo "ServerName\t`cat /etc/hostname`" | sudo tee -a /etc/apache2/apache2.conf
1

的服务器名称添加到/etc/apache2/apache.conf

ServerName [yourservername or localhost] 

and lo ad Apache配置: service apache2 restart

相关问题