nativeInstallerwordpress-multisite

Configure blogs for different domains with different SSL certificates

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: The Approach A sections referred to below do not apply to Bitnami native installers. Users of Bitnami native installers should refer only to the Approach B sections.

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 installdir/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 "installdir/apache2/conf/bitnami/certs/new_server.crt"
        SSLCertificateKeyFile "installdir/apache2/conf/bitnami/certs/new_server.key"
        DocumentRoot installdir/wordpress
        <Directory "installdir/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 "installdir/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 installdir/apache2/conf/vhosts/wordpress-https-vhost.conf file, restart Apache to apply the changes.

      $ sudo installdir/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 installdir/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 "installdir/apps/wordpress/htdocs"
          Include "installdir/apps/wordpress/conf/httpd-app.conf"
      </VirtualHost>
      <VirtualHost *:443>
          ServerName yourserverdomain.com
          ServerAlias *.yourserverdomain.com
          DocumentRoot "installdir/apps/wordpress/htdocs"
          SSLEngine on
          SSLCertificateFile "installdir/apps/wordpress/conf/certs/new_server.crt"
          SSLCertificateKeyFile "installdir/apps/wordpress/conf/certs/new_server.key"
          Include "installdir/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 installdir/apps/wordpress/conf/httpd-vhosts.conf file, include that file in Apache’s installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file as shown below:

      Include "installdir/apps/wordpress/conf/httpd-vhosts.conf"
    
  • After modifying the Apache configuration files, restart Apache to apply the changes:

      $ sudo installdir/ctlscript.sh restart apache
    
Last modification June 16, 2021