title: Apache vhost loads incorrect doc root
body: <p>My issue is that Apache randomly loads a non-default vhost instead of the domain I ask it to.  I've tried just about every solution I found on this site and through searching but nothing seems to fix this problem.</p>
  
  <p>Background:</p>
  
  <ul>
  <li>This is a virtual server hosted on a popular cloud platform</li>
  <li>The global apache conf file contains no VirtualHost definitions and the config file below is included properly (Include sites-enabled/*.conf)</li>
  <li>Apache 2.4 on Ubuntu 16.04</li>
  <li>I had each domain in their own conf file but that did not work either.</li>
  <li>Apache has chosen <strong>domain3.com</strong> as the default for some reason.</li>
  <li>When I execute <code>curl localhost</code> on the server, it returns the contents of domain3.com.</li>
  <li>The only thing excluded from the vhost below are some SSL definitions that don't seem to be causing any problems.</li>
  <li>ServerName is defined as <code>localhost</code> in apache.conf</li>
  <li>The vhosts below are saved at <code>/etc/apache2/sites-enabled/000-default.conf</code></li>
  </ul>
  
  <p>Server weirdness?</p>
  
  <ul>
  <li>I can't seem to actually stop apache.  Executing <code>service apache2 stop</code> and then <code>service apache2 status</code> will identify the process as inactive, but I can still load pages under domain1/2/3.com.  It's like nothing I do has any effect.</li>
  <li>There's like 3 ways to access apache now.  Some seem to work, some don't.  <code>/etc/init.d/apache2</code>, <code>service apache2</code>, <code>apache2ctl</code>.</li>
  <li>It only loads the wrong site about 50% of the time.</li>
  </ul>
  
  <p>I'm completely out of ideas...</p>
  
  <pre><code>NameVirtualHost *:80
  
  # domain1.com
  &lt;VirtualHost *:80&gt;
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      ServerName www.domain1.com
      ServerAlias domain1.com
      UseCanonicalName Off
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/domain1.com/
  
      &lt;Directory /var/www/domain1.com&gt;
              Options Indexes FollowSymLinks
              AllowOverride All
              Require all granted
      &lt;/Directory&gt;
  
      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf
  &lt;/VirtualHost&gt;
  
  # domain3.com
  &lt;VirtualHost *:80&gt;
          # The ServerName directive sets the request scheme, hostname and port that
          # the server uses to identify itself. This is used when creating
          # redirection URLs. In the context of virtual hosts, the ServerName
          # specifies what hostname must appear in the request's Host: header to
          # match this virtual host. For the default virtual host (this file) this
          # value is not decisive as it is used as a last resort host regardless.
          # However, you must set it for any further virtual host explicitly.
          ServerName www.domain3.com
          ServerAlias domain3.com
          ServerAlias domain3.net
          ServerAlias www.domain3.net
          UseCanonicalName Off
          ServerAdmin webmaster@localhost
          DocumentRoot /var/www/domain3.com/
  
          &lt;Directory /var/www/domain3.com&gt;
                  Options Indexes FollowSymLinks
                  AllowOverride All
                  Require all granted
          &lt;/Directory&gt;
  
  
          # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
          # error, crit, alert, emerg.
          # It is also possible to configure the loglevel for particular
          # modules, e.g.
          #LogLevel info ssl:warn
  
          ErrorLog ${APACHE_LOG_DIR}/cq2_error.log
          CustomLog ${APACHE_LOG_DIR}/cq2_access.log combined
  
          # For most configuration files from conf-available/, which are
          # enabled or disabled at a global level, it is possible to
          # include a line for only one particular virtual host. For example the
          # following line enables the CGI configuration for this host only
          # after it has been globally disabled with "a2disconf".
          #Include conf-available/serve-cgi-bin.conf
  &lt;/VirtualHost&gt;
  
  # domain2.com
  &lt;VirtualHost *:80&gt;
          # The ServerName directive sets the request scheme, hostname and port that
          # the server uses to identify itself. This is used when creating
          # redirection URLs. In the context of virtual hosts, the ServerName
          # specifies what hostname must appear in the request's Host: header to
          # match this virtual host. For the default virtual host (this file) this
          # value is not decisive as it is used as a last resort host regardless.
          # However, you must set it for any further virtual host explicitly.
          ServerName www.domain2.com
          ServerAlias domain2.com
          UseCanonicalName Off
          ServerAdmin webmaster@localhost
          DocumentRoot /var/www/domain2.com/
  
          &lt;Directory /var/www/domain2.com&gt;
                  Options Indexes FollowSymLinks
                  AllowOverride All
                  Require all granted
          &lt;/Directory&gt;
  
  
          # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
          # error, crit, alert, emerg.
          # It is also possible to configure the loglevel for particular
          # modules, e.g.
          #LogLevel info ssl:warn
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          # For most configuration files from conf-available/, which are
          # enabled or disabled at a global level, it is possible to
          # include a line for only one particular virtual host. For example the
          # following line enables the CGI configuration for this host only
          # after it has been globally disabled with "a2disconf".
          #Include conf-available/serve-cgi-bin.conf
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And my <code>apache2ctl -S</code> output:</p>
  
  <pre><code>AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-default.conf:1
  VirtualHost configuration:
  *:80                   is a NameVirtualHost
           default server www.domain1.com (/etc/apache2/sites-enabled/000-default.conf:4)
           port 80 namevhost www.domain1.com (/etc/apache2/sites-enabled/000-default.conf:4)
                   alias domain1.com
           port 80 namevhost www.domain3.com (/etc/apache2/sites-enabled/000-default.conf:54)
                   alias domain3.com
                   alias domain3.net
                   alias www.domain3.net
           port 80 namevhost www.domain2.com (/etc/apache2/sites-enabled/000-default.conf:95)
                   alias domain2.com
  ServerRoot: "/etc/apache2"
  Main DocumentRoot: "/var/www/html"
  Main ErrorLog: "/var/log/apache2/error.log"
  Mutex rewrite-map: using_defaults
  Mutex ssl-stapling-refresh: using_defaults
  Mutex ssl-stapling: using_defaults
  Mutex ssl-cache: using_defaults
  Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
  Mutex mpm-accept: using_defaults
  Mutex watchdog-callback: using_defaults
  PidFile: "/var/run/apache2/apache2.pid"
  Define: DUMP_VHOSTS
  Define: DUMP_RUN_CFG
  User: name="www-data" id=33 not_used
  Group: name="www-data" id=33 not_used
  </code></pre>