I have installed an Apache server in CentOS 8 and it was serving both http and https pages correctly, that is, I could view the Apache test page when connected to the server from my browser

I used this tutorial to enable https: https://www.techrepublic.com/article/how-to-enable-https-on-apache-centos/

This much worked. But when I tried to enable the server to serve webpages other that the default test page, I am getting the error "AH00558: httpd: Could not reliably determine server's fully qualified servername error after creating VirtualHost" when trying to restart the apache server using

sudo systemctl restart httpd  

Here are the contents of my /etc/https/conf/http.conf with some comments removed.

ServerRoot "/etc/httpd"
Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
# If your host doesn't have a registered DNS name, enter its IP address here.
#ServerName www.example.com:80

<Directory />
    AllowOverride none
    Require all denied

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

<IfModule dir_module>
    DirectoryIndex index.html

<Files ".ht*">
    Require all denied

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    CustomLog "logs/access_log" combined

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"


<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic

EnableSendfile on

IncludeOptional conf.d/*.conf

IncludeOptional sites-enabled/*.conf

I have a feeling this has something to do with the ServerName entry. It is commented by default as shown above, but I have tried uncommenting it as well as matching it with the coonfiguration in my VirtualHost file, but I am getting the same error.

Here are the contents of the /etc/httpd/sites-available/adorkable.conf

(NOTE: the word adorkable has been replaced with my username, username1)

<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "/var/www/html/username1/"
    ServerName localhost.localdomain
    ServerAlias username1
    ErrorLog /var/www/html/username1/error.log

<Directory "/var/www/html/username1/">
    DirectoryIndex index.html index.php
    Options FollowSymLinks
    AllowOverride All
    Require all granted

Output of systemctl status httpd after issuing a systemctl restart httpd:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2020-05-14 14:53:28 KST; 43s ago
     Docs: man:httpd.service(8)
  Process: 11746 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 11746 (code=exited, status=1/FAILURE)
   Status: "Reading configuration..."

May 14 14:53:28 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
May 14 14:53:28 localhost.localdomain httpd[11746]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
May 14 14:53:28 localhost.localdomain systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
May 14 14:53:28 localhost.localdomain systemd[1]: httpd.service: Failed with result 'exit-code'.
May 14 14:53:28 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.

How do I restart the httpd service here?

UPDATE: the linked tutorial above says that we need to add the following line at the end of httpd.conf

IncludeOptional sites-enabled/*.conf  

This is the only change I have made to the default httpd.conf file, and if I comment this line I can restart httpd normally. So the problem is somewhere in my version of the /etc/httpd/sites-available/adorkable.conf file (renamed to username1.conf in my case. I have a symlink to this file in sites-enabled, created using the command

sudo ln -s /etc/httpd/sites-available/adorkable.conf /etc/httpd/sites-enabled/adorkable.conf  

as instructed in the linked tutorial.

1 Answer 1


The problem is with the line ServerName localhost.localdomain in adorkable.conf. The entire server is running on localhost.localdomain. You should use your actual domain name in your VirtualHost configuration.

ServerName example.com

If the domain name is not yet pointing to the server you can test by putting it into your /etc/hosts file:   example.com www.example.com

Or in some other computer's host file using the actual IP address of your server.

  • If I remove the "ErrorLog /var/www/html/username1/error.log" directive I can restart httpd. It looks like something is preventing me from writing inside "/var/www/html/username1/". Could this be an issue?
    – user17915
    Commented May 14, 2020 at 8:55
  • Any directory the webserver should write to should be created and then owned by user apache or group apache with appropriate write permissions for the user or group. You probably want the logs written to /var/logs/apache/username1 rather than writing logs to the DocumentRoot where they would be publicly visible. Commented May 14, 2020 at 8:59
  • I'm sorry but this is probably a general linux question. Is "/var/logs/apache/" a standard folder for apache logs or am allowed to create it? When I installed Apache should it have created a standard log folder? In my computer I have a /var/log but no /var/logs. Should I just create a folder structure /var/log/apache/username1 and direct ErrorLog to this folder?
    – user17915
    Commented May 14, 2020 at 9:06
  • I created "/var/log/apache/username1", chown apache:apache for both apache and username1 folders and directed ErrorLog to this folder, and this seems to work. Thanks for the help
    – user17915
    Commented May 14, 2020 at 9:20
  • If /var/log exists, use that. The directory structure on Linux differs somewhat between various distributions. I had Googled "CentOS Apache log directory" and found a result that had the plural version, but that may be incorrect information. I use Ubuntu/Debian which uses /var/log/apache2/ It might also be /var/log/httpd/ under CentOs. Commented May 14, 2020 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.