I am currently using an AWS EC2 (ubuntu 20.04) machine. I have installed apache2 and configured a two new sites at /var/www/myapp/myapp.html and /var/www/mynew/mynew.html. I created a new virtualhost file at the location /etc/apache/sites-available/myapp.conf. I have added 2 virtual host entries corresponding to the above sites. Enabled the myapp.conf file (a2ensite myapp.conf) and disabled the default virtualhost file (000-default.conf). As an experiment i put wrong IP:port combinations for the virtualhost directives , so that my request will not match any of the virtualhost. When i am trying to access the server , it serves the default webpage. But i was expecting the 1st virtualhost content.

Does anyone know why the disabled default webpage is displayed if no virtualhost matching the requested IP:port?

1 Answer 1


Finally, I found an answer for my question.

I did more troubleshooting and tried other scenarios as described below,

  1. Made sure the "ports.conf" file configured correctly.
  2. Checked the apache logs - but tbh i did not find any useful information.
  3. As a final check, I deleted the default virtualhost configuration file (the remanamed nmapp-default.conf) -> but even after deleting the file and restarting the server, apache was serving the same default webpage. This made me to think that other than this default virtualHost file, there is some different configuration exist and that redirect the apache to the same default webpage.

My findings :

  1. Ran the command sudo apachectl -S to determine where/how my virtualhosts were actually being loaded
  2. From the output of the command i got "Main DocumentRoot: "/var/www/html"

I searched for this and found the below details.

As the name already suggests, it is the default DocumentRoot value for virtual hosts when they themselves don’t specify one. So if a request matches a virtual host block which lacks a DocumentRoot directive to fulfil the request, Apache will use the default or main document root to serve the request.

Apache default document root specified in two places,

  1. Compile-time or Runtime options of httpd.
  2. The main server config which is the configuration specified outside the virtual host blocks. Any virtual host configuration basically picks up default values from the main server config (In my case, the value was not mentioned anywhere in the main configuration file. ie, apache2.conf, so it must be set during the runtime)

Note: The document root value specified in the main server config will override the one inherited from compile-time or runtime option

In other words, my main DocumentRoot was unconfigured and the default value was used until I explicitly defined it in a global configuration file.

Please refer this link for more information:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .