0

I am trying to set up multiple websites on a single Ubuntu 16.04 installation, and so far have installed Ubuntu with LAMP and SSL (Letsencrypt).

  • Ubuntu 16.04
  • PHP 7.0
  • Apache2
  • MariaDB

Issue: first domain ( website1.com ) points to the right folder ( var/www/html/website1 ), but my second domain ( website2.com) points to the first ( var/www/html/website1 ).

I have created /etc/apache2/sites-available/website1.conf and /etc/apache2/sites-available/website2.conf files and configured as follows:

Website1.conf

<IfModule mod_ssl.c><VirtualHost *:443>
ServerAdmin myemail@gmail.com
ServerName website1.com
ServerAlias www.website1.com
DocumentRoot /var/www/html/website1 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory>
<Directory /var/www/html/website1> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all
</Directory> 
    SSLCertificateFile /etc/letsencrypt/live/website2.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/website2.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Website2.conf

<IfModule mod_ssl.c><VirtualHost *:443>
ServerAdmin myemail@gmail.com
ServerName website2.com
ServerAlias www.website2.com
DocumentRoot /var/www/html/website2
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory>
<Directory /var/www/html/website2> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all
</Directory> 
    SSLCertificateFile /etc/letsencrypt/live/website2.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/website2.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

apachectl -S output

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 website1.com (/etc/apache2/sites-enabled/website1-le-ssl.conf:2)
         port 443 namevhost website1.com (/etc/apache2/sites-enabled/website1-le-ssl.conf:2)
             alias www.website1.com
     port 443 namevhost website2.com (/etc/apache2/sites-enabled/website2-le-ssl.conf:2)
             alias www.website2.com
*:80                   website2.com (/etc/apache2/sites-enabled/website2.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: 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
  • I have enabled (a2ensite) website1.conf and a2ensite website2.conf;
  • I have disabled (a2dissite) 000-default.conf and default-ssl.conf;
  • I have also tried a2ensite default-ssl.conf; I have restarted (sudo
    systemctl restart apache2) after each change.

Each time when I try to access website2.com it gets me straight to website1.com

Please help and many thanks in advance for your ideas!

Scott Agirs
  • 111
  • 2

0 Answers0