Configure blogs for different domains with different SSL certificates
NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:
$ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."
The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.
This section assumes:
- You have a working WordPress Multisite installation
- Your server has a static IP address
- You are able to log in to your server console using a tool like PuTTY (Windows) or SSH (Linux and Mac OS X)
- You own at least one custom domain name for which you can configure DNS settings
- You have defined your primary domain and blog as described here and you are able to log in to the WordPress Multisite dashboard.
- You have added one or more WordPress Multisite blogs with different domains as described here .
Follow these steps depending on your installation type:
Approach A: Bitnami installations using system packages
-
In order to set different SSL certificates for each new domain, configure each domain as a virtual host. Edit the /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf file and add a new virtual host for each new domain. The following code could be taken as an example:
<VirtualHost 127.0.0.1:443 _default_:443> ServerName yourserverdomain.com ServerAlias *.yourserverdomain.com SSLEngine on SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/new_server.crt" SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/new_server.key" DocumentRoot /opt/bitnami/wordpress <Directory "/opt/bitnami/wordpress"> Options -Indexes +FollowSymLinks -MultiViews AllowOverride None Require all granted # BEGIN WordPress fix for plugins and themes # Certain WordPress plugins and themes do not properly link to PHP files because of symbolic links # https://github.com/bitnami/bitnami-docker-wordpress-nginx/issues/43 RewriteEngine On RewriteRule ^bitnami/wordpress(/.*) $1 [L] # END WordPress fix for plugins and themes# BEGIN nip.io redirection RewriteEngine On RewriteCond %{HTTP_HOST} ^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(:[0-9]{1,5})?$ RewriteRule ^/?(.*) %{REQUEST_SCHEME}://%1.nip.io%2/$1 [L,R=302,NE] # END nip.io redirection# BEGIN WordPress Multisite # Using subdomain network type: https://wordpress.org/support/article/htaccess/#multisite RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) $1 [L] RewriteRule ^(.*\.php)$ $1 [L] RewriteRule . index.php [L] # END WordPress Multisite </Directory> Include "/opt/bitnami/apache2/conf/vhosts/htaccess/wordpress-htaccess.conf" </VirtualHost>
Remember to change the ServerName and ServerAlias directives to the correct values.
To specify a different SSL certificate for each domain, update the paths to the corresponding certificate files in the SSLCertificateFile and SSLCertificateKeyFile directives.
-
After ensuring that the certificates are properly generated and configured in the /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf file, restart Apache to apply the changes.
$ sudo /opt/bitnami/ctlscript.sh restart apache
Approach B: Self-contained Bitnami installations
-
In order to set different SSL certificates for each new domain, configure each domain as a virtual host. Edit the /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf file and add a new virtual host for each new domain. The following code could be taken as an example:
<VirtualHost *:80> ServerName yourserverdomain.com ServerAlias *.yourserverdomain.com DocumentRoot "/opt/bitnami/apps/wordpress/htdocs" Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf" </VirtualHost> <VirtualHost *:443> ServerName yourserverdomain.com ServerAlias *.yourserverdomain.com DocumentRoot "/opt/bitnami/apps/wordpress/htdocs" SSLEngine on SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/new_server.crt" SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/new_server.key" Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf" </VirtualHost>
Remember to change the ServerName and ServerAlias directives to the correct values.
To specify a different SSL certificate for each domain, update the paths to the corresponding certificate files in the SSLCertificateFile and SSLCertificateKeyFile directives.
-
After ensuring that the certificates are properly generated and configured in the /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf file, include that file in Apache’s /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf file as shown below:
Include "/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf"
-
After modifying the Apache configuration files, restart Apache to apply the changes:
$ sudo /opt/bitnami/ctlscript.sh restart apache