httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

前端 未结 12 1734
悲&欢浪女
悲&欢浪女 2020-12-04 05:44

I tried to restart my Apache server on CentOS 5.0 and got this message:

httpd: Could not reliably determine the server\'s fully qualified domain name,

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 06:16

    So while this is answered and accepted it still came up as a top search result and the answers though laid out (after lots of research) left me scratching my head and digging a lot further. So here's a quick layout of how I resolved the issue.

    Assuming my server is myserver.myhome.com and my static IP address is 192.168.1.150:

    1. Edit the hosts file

      $ sudo nano -w /etc/hosts
      
      127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
      
      127.0.0.1 myserver.myhome.com myserver
      
      192.168.1.150 myserver.myhome.com myserver
      
      ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
      ::1 myserver.myhome.com myserver
      
    2. Edit httpd.conf

      $ sudo nano -w /etc/apache2/httpd.conf
      
      ServerName myserver.myhome.com
      
    3. Edit network

      $ sudo nano -w /etc/sysconfig/network HOSTNAME=myserver.myhome.com
      
    4. Verify

      $ hostname
      
      (output) myserver.myhome.com
      
      $ hostname -f
      
      (output) myserver.myhome.com
      
    5. Restart Apache

      $ sudo /etc/init.d/apache2 restart
      

    It appeared the difference was including myserver.myhome.com to both the 127.0.0.1 as well as the static IP address 192.168.1.150 in the hosts file. The same on Ubuntu Server and CentOS.

提交回复
热议问题