Add a <VirtualHost> block for each secure site on the server

For each domain name or domain subset we want to support SSL for, a VirtualHost block must be declared. This block identifies the domain name to support connections for, and what Certificate or Key files to use for it.

  1. Navigate to /etc/apache2/sites-enabled and open the folder for the secure site.
  2. Open the <site_name>.conf file in an editor.
  3. Add the <virtualhost> block for the secure server.

The block will look similar to this:

<VirtualHost *:443>

ServerName "secure2.example.com"

ServerAdmin webmaster@example.com

DocumentRoot /home/demo/public_html/secure1.example.com/public

ErrorLog /home/demo/public_html/secure2.example.com/log/error.log

LogLevel warn

CustomLog /home/demo/public_html/secure2.example.com/log/access.log combined

<Directory /home/demo/public_html/secure2.example.com/public>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

</Directory>

SSLEngine On

SSLCertificateFile /var/www/certs/secure2.pem

SSLCertificateKeyFile /var/www/keys/secure2.key

</VirtualHost>

Update the sample block to reflect the file locations on your Apache server, and ensure each block references the correct secure site.

  1. Save the configuration file.