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

前端 未结 12 1711
悲&欢浪女
悲&欢浪女 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:04

    If you've edited /etc/apache2/httpd.conf with the ServerName localhost you may be editing the wrong file. All answers I found were pointing towards that standard httpd.conf. After some foraging, I found a good answer here.

    To locate the right httpd.conf file use

    apachectl -t -D DUMP_INCLUDES
    

    I found mine was actually /usr/local/etc/httpd/httpd.conf.

    Use your preferred editor to comment out the line (i.e. remove the # before) starting with ServerName, and replace the domain name for the appropriate one – local environments should work with

    ServerName localhost
    

    I hope this helps more people who may be stuck.

    0 讨论(0)
  • 2020-12-04 06:08

    Turns out that I had this problem and it was because I used "tabs" to indent lines instead of spaces. Just posting, in case it helps anyone.

    0 讨论(0)
  • 2020-12-04 06:11

    In the Apache httpd.conf file:

    ServerName: 127.0.0.1
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-04 06:16

    There are two ways to resolve this error:

    1. Include /etc/apache2/httpd.conf

      Add the above line in file /etc/apache2/apache2.conf

    2. Add this line at the end of the file /etc/apache2/apache2.conf:

      ServerName localhost

    0 讨论(0)
  • 2020-12-04 06:19

    In httpd.conf, search for "ServerName". It's usually commented out by default on Mac. Just uncomment it and fill it in. Make sure you also have the name/ip combo set in /etc/hosts.

    0 讨论(0)
提交回复
热议问题