# [Solved] Apache not recognising the hostname

## dansou90

Hello,

I've got a little problem. Every time I start my apache it says

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

I am aware that other people had this problem, too. I solved it a few years ago on a Debian system which is running fine right now, and tried to fix it the same way in Gentoo, but it didn't work. Thats what I tried so far:

in /etc/hosts, I've done this (these are the settings from my Debian system):

```
127.0.0.1       localhost

127.0.0.1       daniel-pc
```

In my vhosts I've added the ServerName directive with the right hostname (daniel-pc).

In case it is important: I am using ssl with a self signed certificate and a RewriteRule for port 80, so all requests will be redirected to port 443. I copied the config over from my Debian system:

```
<VirtualHost *:80>

        ServerName daniel-pc

        RewriteEngine On

        RewriteCond %{HTTPS} !=on

        RewriteRule ^/(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R]

        <IfModule mpm_peruser_module>

                ServerEnvironment apache apache

        </IfModule>

</VirtualHost>
```

My config for the ssl vhost looks this way:

```
<VirtualHost _default_:443>

        ServerName daniel-desktop

        Include /etc/apache2/vhosts.d/default_vhost.include

        ErrorLog /var/log/apache2/ssl_error_log

        <IfModule log_config_module>

                TransferLog /var/log/apache2/ssl_access_log

        </IfModule>

        SSLEngine on

        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

        SSLCertificateFile /etc/ssl/apache2/daniel-pc.crt

        SSLCertificateKeyFile /etc/ssl/apache2/daniel-pc.key

        ServerName daniel-pc

        SSLOptions StrictRequire

        SSLProtocol all -SSLv2

        DocumentRoot /var/www/localhost/htdocs

        <Directory /var/www/localhost/htdocs/>

                SSLRequireSSL

                Order Deny,Allow

                Allow from All

        </Directory>

        <FilesMatch "\.(cgi|shtml|phtml|php)$">

                SSLOptions +StdEnvVars

        </FilesMatch>

        <Directory "/var/www/localhost/cgi-bin">

                SSLOptions +StdEnvVars

        </Directory>

        <IfModule setenvif_module>

                BrowserMatch ".*MSIE.*" \

                        nokeepalive ssl-unclean-shutdown \

                        downgrade-1.0 force-response-1.0

        </IfModule>

        <IfModule log_config_module>

                CustomLog /var/log/apache2/ssl_request_log \

                        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

        </IfModule>

</VirtualHost>
```

Apache is running just fine, but this error bothers me... is there any way getting rid of it?Last edited by dansou90 on Mon May 07, 2012 11:00 am; edited 1 time in total

----------

## sebaro

$ echo "ServerName localhost" >> /etc/apache2/httpd.conf

----------

## dansou90

Thank you sebaro, adding the ServerName directive to httpd.conf worked!

----------

