2

I am trying to implement a second domain within an existing digitalocean droplet.

Because I'm on DO, I followed the answer by ryanpq on this thread: https://www.digitalocean.com/community/questions/is-it-possible-to-install-another-wordpress-on-droplet

Similar to the commenters on that thread, my newer site redirects to my existing site (even after changing the DocumentRoot and Directory appropriately).

Here are my configs:

Within /etc/apache2/sites-enabled, I have 4 files: 000-default-le-ssl.conf 000-default.conf example1.conf example2.conf

000-default.conf and example1.conf are copies.

example1.conf looks like so:

# Added to mitigate CVE-2017-8295 vulnerability
UseCanonicalName On

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ServerName example1.io
        ServerAlias www.example1.io

        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example1.io [OR]
RewriteCond %{SERVER_NAME} =example1.io
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

example2.conf looks like so:

<VirtualHost *:80>
        ServerAdmin webmaster@example2.com

        ServerName example2.com
        ServerAlias www.example2.com

        DocumentRoot /var/www/example2

        <Directory /var/www/example2/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

my directory structure looks like /var/www/html and /var/www/example2

Within the DNS control panel, I created new A and CNAME records. The A record points to the IP address of the older, existing, site (so, example2.com directs to 128....)

Going to example2.com redirects me to example1.io.

What am I missing?

Jay Jung
  • 121
  • 3

1 Answers1

2

Configuration error?

First of all, your example1.conf file does not contain a closing </VirtualHost> tag. Since this file gets loaded before example2.conf the second domain probably does not get loaded correctly. Do you get any errors when reloading Apache? You can use mod_info to verify both virtual hosts are loaded correctly.

Domain Name System

I do not fully understand your remarks about DNS. You mention "IP address of the older site" as if the new site has a different IP address? As your same virtual machine (droplet) hosts both websites, all names should point towards this one IP address of the virtual machine, either directly (A record) or indirectly (CNAME record).

For example:

example1.io.        A       203.0.113.80
www.example1.io.    CNAME   example1.io

example2.com.       A       203.0.113.80
www.example2.com.   A       203.0.113.80

You can test and verify all the names point to the same IP address by using ping or dig from a command-line interface.

HTTPS

What does your 000-default-le-ssl.conf file looks like as you redirect example1.io to HTTPS. Are you testing example2.com via HTTP or HTTPS?

Logs

When you visit http://www.example2.com/ and you are presented with the web page of example1.io, what do you logs show?

Tommiie
  • 5,627
  • 2
  • 12
  • 46