Multiple Domain and Multiple Certificates in Apache

1.    How to make a certificate for your domain

We use snapd for the certificate generation.

You can see the information of domain in your .conf for apache2.

Then, you can select 1, 2 for both domains.

Finally, you made a certificate for both domains.

1.1.           Small tips

 

 

planation:

·         % to refer the next command to work on all the lines

·         y to yank those lines

·         + to copy to the system clipboard

NB: In Windows, + and * are equivalent see this answer.

If anyone is getting E850: Invalid register name error, try :%y"+ to copy all content to the clipboard and "+p to paste it (thanks to @deadLock)

 


Ok, now we have the conf file as blow.

<VirtualHost *:80>

    ServerName www.phdson.com

    ServerAlias www.phdson.com

    Redirect permanent / https://www.phdson.com/

    RewriteEngine on

    RewriteCond %{SERVER_NAME}=www.phdson.com

    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

 

<VirtualHost  *:443>

    ServerName www.phdson.com

    ServerAlias www.phdson.com

    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

    SSLEngine on

    SSLProtocol all -SSLv2

    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5

    Include /etc/letsencrypt/options-ssl-apache.conf

 

    SSLCertificateFile /etc/letsencrypt/live/www.phdson.com/fullchain.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/www.phdson.com/privkey.pem

</VirtualHost>

 

<VirtualHost *:443>

    ServerName phdson.com

    DocumentRoot /var/www/html

 

    SSLEngine on

    SSLCertificateFile /etc/letsencrypt/live/phdson.com/fullchain.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/phdson.com/privkey.pem

</VirtualHost>

 

# VirtualHost configuration for biz.phdson.com

<VirtualHost *:443>

    ServerName biz.phdson.com

    DocumentRoot /var/www/html

 

    SSLEngine on

    SSLCertificateFile /etc/letsencrypt/live/biz.phdson.com/fullchain.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/biz.phdson.com/privkey.pem

</VirtualHost>

 

Alias /dynamic/static /home/pi/pidjango/static

<Directory /home/pi/pidjango/static>

    Require all granted

</Directory>

 

<Directory /home/pi/pidjango>

    <Files wsgi.py>

        Require all granted

    </Files>

</Directory>

WSGIDaemonProcess pidjango python-path=/home/pi/pidjango python-home=/home/pi/djenv

WSGIProcessGroup pidjango

WSGIScriptAlias /dynamic /home/pi/pidjango/pidjango/wsgi.py