Question

Multiple domains on one droplet (multiple vhosts issue)

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
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

Indeed as azaraks you could try creating a Vhost for port 443. In order to do that you would need an SSL certificate.

I would suggest just using Let’s Encrypt and certbot, that way certbot would generate the Vhost for port 443 automatically for you.

You could follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-18-04

Regards, Bobby

This comment has been deleted