Best way Multiple WordPress on Single Server Bitnami NGINX 2021

If you handle more than one WordPress blog and want to install all these multiple WordPress websites or blogs on a single Virtual Machine (VM) then this article is for you. This tutorial is for WordPress with NGINX and SSL Certified by Bitnami and Automattic on the Google Cloud. You can learn how you can install the WordPress NGINX bitnami stack here.

Multiple WordPress Single Virtual Machine VM
WordPress NGINX Single VM Installation

Please note that this will guide you on how you can install multiple different WordPress not multisite. This bitnami stack already running a WordPress on this VM, now we’re adding the second WordPress. You can find the installation of the 1st WordPress application here. This article guides how you can install a second WordPress application on the virtual machine.

Installation of Multiple WordPress using Single Virtual Machine VM Bitnami NGINX

After the successful installation of WordPress NGINX bitnami stack, you can follow this step of adding multiple WordPress application in your bitnami stack. But the question may arise that

Why should one install multiple WordPress on a single VM?

You might already know the answer as you’re already here. These are some major point could be the reason.

  • Handling Multiple VM could be tough.
  • If you’ve already a virtual machine why create so many? It would be like you have to use a different browser on a different computer.
  • From the above line, you can understand usage cost could be very high for different VM. We can save our hard-earned money using a single virtual machine,
  • This may allow you to choose a strong dedicated virtual machine instead of multiple small shared machines.
  • Drawback: Could be that you can’t install one WordPress in India and one in the US region. But both WordPress will work fine globally.

Add Database for the Second WordPress using PHPMyAdmin.

In the bitnami stack, PHPMyAdmin is very secure and you can’t access it directly by visiting a URL. Learn how to connect PHPMyAdmin in the bitnami stack.

create database using phpmyadmin

Add MultiPress WordPress create files in the VM.

First of all, you’ve to open SSH Terminal, If you don’t know how to do it please refer to this tutorial of SSH. And you’ve to download the WordPress application to the Bitnami application folder.

To do that, you’ve to access SSH with root permission,

sudo -i

Download New WordPress Application to the application folder

First we’ll go to the application folder, execute the command line.

cd /opt/bitnami/apps/

Now Create a New folder in this directory, we are creating a new folder with the name “techaak”. You can choose any name but in the following command, you’ve to change techaak with your folder name.

Download Wordpress zip and extract

Execute the followings lines one by one.

mkdir techaak
cd techaak
wget http://wordpress.org/latest.tar.gz
tar xfz latest.tar.gz
mv wordpress htdocs

Now we downloaded the latest WordPress application to the virtual machine. To run multiple WordPress we’ve to connect this WordPress to the present environment of the single virtual machine. To do that let’s create configuration files.

Configuration files for the New WordPress Application.

We’ll create files according to the bitnami environment. To do that executes these command one by one

mkdir conf
cd conf
nano nginx-app.conf

Now a blank window or new file window is open-up, you’ve to paste the following lines in that

index index.php index.html index.htm;

if ($request_uri !~ "^/phpmyadmin.*$")
  set $test  A;
if ($request_uri !~ "^/bitnami.*$")
  set $test  "${test}B";
if (!-e $request_filename)
  set $test  "${test}C";
if ($test = ABC) {
  rewrite ^/(.+)$ /index.php?q=$1 last;

# Deny access to any files with a .php extension in the uploads directory
location ~* /(?:uploads|files)/.*\.php$ {
  deny all;

# Disable logging for not found files and access log for the favicon and robots

# Deny all attempts to access hidden files such as .htaccess or .htpasswd.
location ~ /\. {
    deny all;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_read_timeout 300;
    fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME $request_filename;
    include fastcgi_params;

Press ctrl+x(windows) or cmd+x(mac), Then Y to confirm the changes and then Press Enter.

Now We’ll create second configuration file.

nano nginx-prefix.conf

In the new blank window paste these lines.

location /techaak {
alias "/opt/bitnami/apps/techaak/htdocs";
include "/opt/bitnami/apps/techaak/conf/nginx-app.conf";

Now save this file by pressing Ctrl+X, then Y and then enter. Now we’ll create the host file. Execute the following command.

nano nginx-vhosts.conf

A new blank window will open up, paste the following code in that, replace it with your values(red letters).

server {

    listen    80;
    root   "/opt/bitnami/apps/techaak/htdocs";
    server_name  example.com www.example.com;
    include "/opt/bitnami/apps/wordpress/conf/nginx-app.conf";

server {

    listen    443 ssl;
    root   "/opt/bitnami/apps/techaak/htdocs";
    server_name  example.com www.example.com;

      ssl_certificate      /opt/bitnami/nginx/conf/server.crt;
       ssl_certificate_key  /opt/bitnami/nginx/conf/server.key;

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
#change this folder name
    include "/opt/bitnami/apps/techaak/conf/nginx-app.conf";

Save the changes by pressing ctrl+x, then Y and then enter.

Now all the configuration of your wordpress environment is done but not of bitnami nginx stack.

Connect the configuration with bitnami stack

Now you’ve make some changes in the bitnami stack so here, execute the following command to do that.

cd /opt/bitnami/nginx/conf/bitnami
nano bitnami-apps-prefix.conf

now a new SSH window will open up, add the following lines to that

include "/opt/bitnami/apps/techaak/conf/nginx-prefix.conf";

Save the change by pressing Ctrl+X, then Y and then enter. your changes will save.

Now connect the host file to the main bitnami stack.

execute the following command now.

nano bitnami-apps-vhosts.conf
include "/opt/bitnami/apps/techaak/conf/nginx-vhosts.conf";

Save the file using ctrl+x, then Y and then press enter.

Now all done for the Multiple WordPress on Single Virtual Machine. Now new WordPress is connected with the existing bitnami WordPress application.

Check that all settings are correct by executing

nginx -t

If it responds as ok, then fine, or in case of any error then check all steps you performed.

Set the default public permissions to new wordpress application.

sudo chown bitnami:daemon -R /opt/bitnami/apps/techaak/htdocs/*
sudo chmod -R g+w /opt/bitnami/apps/techaak/htdocs*

Now restart the nginx, execute the following command.

sudo /opt/bitnami/ctlscript.sh restart nginx

Update DNS of New WordPress

Visit the domain name provider’s account and point the IP of the single virtual machine to your website. Check Domain Name Configuration.

Access the New WordPress

You can now access your new wordpress website(offcourse after DNS update).

SSL certificate configuration of new WordPress Application

When you create multiple wordpress in Single Virtual Machine you need to setup separate SSL certificate. You’ve to provide path of this SSL certificate in nginx-vhost.conf instead of bitnami.

Generate New SSL certificate, execute the command one by one.

sudo /opt/bitnami/ctlscript.sh stop nginx
sudo /opt/bitnami/letsencrypt/lego --tls --email="admin@tezblog.com " --domains="example.com" --domains="www.example.com" --path="/opt/bitnami/letsencrypt" run
sudo /opt/bitnami/ctlscript.sh start nginx

please change email address and domain name with your own values.

Now point the new SSL certificate to the latest WordPress install. Execute the following command.

nano /opt/bitnami/apps/techaak/conf/nginx-vhosts.conf

Now add the new certificates and comment out old, you new nginx-vhosts.conf file would look like. You can get detailed information in this article.

server {

    listen    80;
    root   "/opt/bitnami/apps/techaak/htdocs";
    server_name  example.com www.example.com;
    include "/opt/bitnami/apps/wordpress/conf/nginx-app.conf";

server {

    listen    443 ssl;
    root   "/opt/bitnami/apps/techaak/htdocs";
    server_name  example.com www.example.com;

#no need to change SSL certificate path.
#    ssl_certificate "/opt/bitnami/apps/wordpress/conf/certs/server.crt";
 #   ssl_certificate_key "/opt/bitnami/apps/wordpress/conf/certs/server.key";
#new certificate below the line.
ssl_certificate_key  "/opt/bitnami/letsencrypt/certificates/iasrank.in.key";

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
#change this folder name
    include "/opt/bitnami/apps/techaak/conf/nginx-app.conf";

Now test the nginx configuration, execute

nginx -t

Now after successful verification, reload the new changes we made into the application.

nginx -s reload

Done your new WordPress application can be access through the URL you provided.

Ashok Kumar

Love Coding, Love Blogging what else to explain :).

Related Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button