Error: Site [domain.com] does not exist when attempting to enable site on Apache

You are here:
< Back

Problem

Issuing the command a2ensite on an Apache web server results in the following error:

Error:  Site [domain.com] does not exist

where [domain.com] is the name of the configuration file / domain name to be enabled.

Also, attempting to manually link the configuration file to the sites-enabled directory also fails to load the configuration successfully.

Background / Cause

If all of the following prerequisites have been verified:

  • the configuration file is attempting to load a configuration from a file that does in fact exist
  • the file has the correct permissions set to allow reading from the file
  • it is in the proper location (usually /etc/apache2/sites-available)

The more elusive issue (apparently showing up on recent versions of the Apache web server) is Apache code is now requiring more explicit syntax.  If the configuration file doesn’t end in “.conf”, Apache no longer recognizes the file as a valid Apache web server site file and the error above is produced.

Resolution

The solution to this error (given everything else is configured correctly) is simple.  Adding the “.conf” extension to the configuration file clears up the error message.
An example would be the following:the original name of the configuration file is mydomain.comThe new name of the accepted configuration file is mydomain.com.confThe rest of the configuration file name doesn’t need to change, simply adding the .conf extension to the existing name will allow the site configuration to be loaded successfully.

Known Issues / Troubleshooting

none at this time.

References

The information provided here was compiled from several different locations, but the bulk of the information matched with the answer found at the following bulletin board URL:

http://stackoverflow.com/questions/10557770/adding-subdomain-to-apache2-with-a2ensite-causes-error-error-site-domain-com-d

Last Updated On October 24, 2017