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

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

    Make sure you're editing the right httpd.conf file, then the error about unreliable server's domain name should be gone (this is the most common mistake).

    To locate your httpd.conf Apache configuration file, run:

    apachectl -t -D DUMP_INCLUDES
    

    Then edit the file and uncomment or change ServerName line into:

    ServerName localhost
    

    Then restart your apache by: sudo apachectl restart

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

    I've resolved the fully qualified domain name message on different occasions by adding my server hostname to the /etc/apache2/httpd.conf file and to the /etc/apache2/apache2.conf file.

    Type hostname -f in your terminal. This query will return your hostname.

    Then edit the /etc/apache2/httpd.conf file (or create it if it does not exist for some reason) and add ServerName <your_hostname>.

    Alternatively, I have also been able to eliminate the message by adding ServerName <your_hostname> to the /etc/apache2/apache2.conf file.

    If all goes well, when you restart Apache, the message will be gone.

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

    After the initial install of Apache server, I got the following error while restarting the Apache service on Ubuntu 12.04 (Precise Pangolin)

    The solution is really simple. Just add the ServerName directive to /etc/apache2/httpd.conf:

    sudo nano /etc/apache2/httpd.conf
    

    Add: ServerName localhost

    Finally restart the Apache server:

    sudo /etc/init.d/apache2 restart
    
    0 讨论(0)
  • 2020-12-04 06:26

    Most answers suggest to just add ServerName localhost to /etc/apache2/apache2.conf.

    But quoting Apache documentation :

    The presence of this error message also indicates that Apache httpd was unable to obtain a fully-qualified hostname by doing a reverse lookup on your server's IP address. While the above instructions will get rid of the warning in any case, it is also a good idea to fix your name resolution so that this reverse mapping works.

    Therefore adding such a line to /etc/hosts is probably a more robust solution :

    192.0.2.0  foobar.example.com  foobar
    

    where 192.0.2.0 is the static IP address of the server named foobar within the example.com domain.

    One can check the FQDN e.g. with

    hostname -A
    

    (shortcut for hostname --all-fqdn).

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

    Your hosts file does not include a valid FQDN, nor is localhost an FQDN. An FQDN must include a hostname part, as well as a domain name part. For example, the following is a valid FQDN:

    host.server4-245.com
    

    Choose an FQDN and include it both in your /etc/hosts file on both the IPv4 and IPv6 addresses you are using (in your case, localhost or 127.0.0.1), and change your ServerName in your httpd configuration to match.

    /etc/hosts:

    127.0.0.1    localhost.localdomain localhost host.server4-245.com
    ::1          localhost.localdomain localhost host.server4-245.com
    

    httpd.conf:

    ServerName host.server4-245.com
    
    0 讨论(0)
  • 2020-12-04 06:28

    If you don't have httpd.conf in folder /etc/apache2, you should have apache2.conf - simply add:

    ServerName localhost

    Then restart the apache2 service.

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