'apache2 configuring two domains in same server

I am trying to configure two domains in one server. My environment is

My domain 1 is : www.streetview.live

My domain 2 is : www.riverview.live

Ubuntu 20.04 PHP 7 apache2

In my /etc/apache2/sites-enabled/000-default.conf I have the created the links for both the domains one after the other.

First for www.streetview.live

<VirtualHost *:80>
        ServerName www.streetview.live
        ServerAlias streetview.live
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/streetview
       <Directory /var/www/html/streetview>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName www.streetview.live
ServerAlias streetview.live
DocumentRoot /var/www/html/streetview
SSLEngine on
SSLCertificateFile /etc/ssl/certs/streetview/www_streetview_live.crt
SSLCertificateKeyFile /etc/ssl/certs/streetview/www_streetview_live.key
SSLCertificateChainFile /etc/ssl/certs/streetview/www_streetview_live.ca-bundle
</VirtualHost>

Followed by www.riverview.live

<VirtualHost *:80>
        ServerName www.riverview.live
        ServerAlias riverview.live
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/riverview
       <Directory /var/www/html/riverview>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName www.riverview.live
ServerAlias riverview.live
DocumentRoot /var/www/html/riverview
SSLEngine on
SSLCertificateFile /etc/ssl/certs/riverview/www_riverview_live.crt
SSLCertificateKeyFile /etc/ssl/certs/riverview/www_riverview_live.key
SSLCertificateChainFile /etc/ssl/certs/riverview/www_riverview_live.ca-bundle
</VirtualHost>

I have loaded all the files in the path /var/www/html/. I have one folder for streetview.live and another for riverview.live as follows

/var/www/html/streetview/
/var/www/html/riverview/

In the DNS server I have mapped the IP to www.streetview.live and similarly for the other site.

However, When I load the page, I face two problems.

  1. The respective sites open only when I use www.streetview.live/streetview on the browser and similarly for riverview.live, I have to use www.riverview.live/riverview`.

  2. For both the https is not getting enabled.

The server is hosted in AWS and I do have the ports opened in Security Group.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source