Multiple domains on one droplet (multiple vhosts issue)

January 3, 2018 748 views
Apache Ubuntu 16.04

Hi folks,

I have added two domains to my droplet (rd-ck.com and braw.io) – both seem to be set up correctly.

I'm then running rd-ck.com from the /var/www/html/ directory and braw.io from the /var/www/braw.io/ directory. I also have a sub-domain set up dev.rd-ck.com which seems to be working fine.

I have just added a braw.io.conf file to /etc/apache2/sites-available, and enabled the .conf file using a2ensite and this is what it contains:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName braw.io
        DocumentRoot /var/www/braw.io

        <Directory /var/www/braw.io/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

RewriteEngine on
RewriteCond %{SERVER_NAME} =braw.io
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

However it braw.io seems to be showing the contents of /var/www/html/ and not /var/www/braw.io/

I have ran a apache2ctl -S command and this is the output:

root@dev:~# apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server rd-ck.com (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
         port 443 namevhost rd-ck.com (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
                 alias www.rd-ck.com
         port 443 namevhost dev.rd-ck.com (/etc/apache2/sites-enabled/dev.rd-ck.com-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost braw.io (/etc/apache2/sites-enabled/braw.io.conf:1)
         port 80 namevhost dev.rd-ck.com (/etc/apache2/sites-enabled/dev.rd-ck.com.conf:1)
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 ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
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
3 comments
  • You need to configure port 443 setting for braw.io.

  • Can you explain how and why?

  • And the content of my 000-default.conf file is:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
    
            <Directory /var/www/html/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            <IfModule mod_dir.c>
                DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
            </IfModule>
    
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =rd-ck.com [OR]
    RewriteCond %{SERVER_NAME} =www.rd-ck.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>
    
    
1 Answer
Have another answer? Share your knowledge.