Rohit Changediya
Rohit Changediya

Reputation: 31

virtual host setup shows default apache2 page

I have setup a new virtual host on my ubuntu 16.04 machine but it redirects me to apache's default virtual host (which is disabled). Below is the contents of the apache virtual hosts config file;

VirtualHost configuration:

*:80 roomba.dev (/etc/apache2/sites-enabled/roomba.dev.conf:2)

*:443 is a NameVirtualHost

default server roomba.dev (/etc/apache2/sites-enabled/default-ssl.conf:2)

port 443 namevhost roomba.dev (/etc/apache2/sites-enabled/default-ssl.conf:2)

port 443 namevhost roomba.dev (/etc/apache2/sites-enabled/roomba.dev.conf:10)

ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

the domain is https://roomba.dev

Upvotes: 0

Views: 503

Answers (1)

Phume
Phume

Reputation: 77

You do not really have a question but based on the fact that I too am trying to setup a virtual host if not several, I have found a work around for the official Ubuntu virthost setup tutorial and the associated docs . They just do not work, see these comments and the confusion that ensued. I am assuming the were providing a clean way to add virtualhosts, similar to how you add APT lists in Linux.

Define your new virtual host in the default-ssl.conf file:

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html

...

  </VirtualHost>
</IfModule>

I hope that you did not delete it. After that first virtual host closing tag, add a new host as described in the tutorial instead of creating a new configuration file. For example;

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>

...

  </VirtualHost>
  <VirtualHost *:80>
    #ServerAdmin admin@roomba.dev
    DocumentRoot /path/to/new/virtualhost
    ServerName roomba.dev
    ErrorLog ${APACHE_LOG_DIR}/roomba-error.log
    CustomLog ${APACHE_LOG_DIR}/roomba-access.log combined
   </VirtualHost>
</IfModule>

You can add as many as you want. I am still searching for documentation that could discourage this with explanations. As again, the Apache tutorial does not work but this does, yet they bothered to write it that way, several times. There must be a reason why.

NB: do not touch any permissions. Except the original virtual server directories, based on the http error codes.

Upvotes: 0

Related Questions