Installing multiple copies of WordPress on Linux Mint 18

multisite

While WordPress has multisite capabilities there might be occasions where you want multiple WordPress sites on your computer.  This might be when you’re creating sites for multiple clients but each will be hosted separately, maybe with clients having their own hosting providers.

Before going any further you will need to ensure that you have installed LAMP.  Instructions can be found in this post.

Setting the Scene

We are going to create two WordPress sites with two separate databases. You could create more.  The following will give some context to what we will be doing:

Name of Site Database Name Database User Database Password
site1 wordpress1 wordpressuser1 password1
site2 wordpress2 wordpressuser2 password2

 

Create a MySQL database

The first step is to create two MySQL databases with usernames and passwords. Open your command line terminal and type in:

mysql -u root -p

You will then be prompted to enter your MySQL password which you created while creating LAMP. You should be switched to the mysql console (“mysql>”).

mysql-console

We’ll now create the database, a user and password. The databases will be called ‘wordpress1’ and ‘wordpress2’. Type in:

CREATE DATABASE wordpress1;
CREATE DATABASE wordpress2;
CREATE USER wordpressuser1@localhost IDENTIFIED BY 'password1';
CREATE USER wordpressuser2@localhost IDENTIFIED BY 'password2';

Ensure that ‘password1‘ and ‘password2‘ are replaced with secure passwords of your choosing.

 

To assign privileges for the user to use the MySQL database type in:

GRANT ALL PRIVILEGES ON wordpress1.* TO wordpressuser1@localhost;
GRANT ALL PRIVILEGES ON wordpress2.* TO wordpressuser2@localhost;

 

To apply these privileges to the MySQL type in:

FLUSH PRIVILEGES;

 

Exit mysql by typing:

exit

 

Configuring Site Root Directories

We will be installing both of the sites within individual directories in the web root of our computer. We will need to change to the ‘/var/www/html/’ directory:

cd /var/www/html/

 

We can then create a directory for each of our sites. These will store the site files.

sudo mkdir site1
sudo mkdir site2

 

Having done this change your directory back:

cd

 

Installing WordPress

We can now download the WordPress files which we need by typing into your command line terminal:

wget http://wordpress.org/latest.tar.gz

 

The above command will save WordPress to your home directory. You will then need to extract all the WordPress files and install some dependency packages:

tar xzvf latest.tar.gz
sudo apt-get update && sudo apt-get install php7.0-gd libssh2-php

 

To change the present working directory to WordPress type into your terminal:

cd wordpress

 

By typing in ls you can then see the content of your WordPress folder. It should look something like:

wordpress-files-ls

Within the above list there is file called ‘wp-config-sample.php’. We want to create a copy of this file which is called ‘wp-config.php’. To do this type:

cp wp-config-sample.php wp-config.php

If you type in ls again you should see the wp-config.php is now added.

wordpress-files-ls2

 

Copy the files to the site root directories:

sudo rsync -avP ~/wordpress/ /var/www/html/site1
sudo rsync -avP ~/wordpress/ /var/www/html/site2

 

Give ownership of the directories to the Apache web user and then add your linux username to the web group:

sudo chown www-data:www-data * -R
sudo usermod -a -G www-data your-linux_user_name

 

Change back to the main directory:

cd

 

First Site Configuration

Change directories to the first site’s document root:

cd /var/www/html/site1

 

Open the WordPress configuration file for editing:

sudo nano wp-config.php

 

Scroll down until you find the fields below and substitute the database, username and password for your site:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress1‘);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser1‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password1‘);

Make sure that you save the file.

 

Second Site Configuration

Change directories to the second site’s document root:

cd /var/www/html/site2

 

Open the WordPress configuration file for editing:

sudo nano wp-config.php

 

Scroll down until you find the fields below and substitute the database, username and password for your site:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress2‘);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser2‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password2‘);

Make sure that you save the file.

 

Create an uploads folder for each site

Change your directory:

cd /var/www/html/site1

 

Within this folder we want to create a folder for uploads by typing:

sudo mkdir wp-content/uploads

 

Do the same for site2:

cd /var/www/html/site2

 

Create the folder for uploads by typing:

sudo mkdir wp-content/uploads

 

Setting up the WordPress sites

In order to see your new WordPress sites, simply navigate to your domain names in a web browser, i.e.

localhost/site1
localhost/site2

If you have configured everything correctly, you should be greeted by the WordPress welcome screen.

 

Hope the above has been useful.  If you have any useful suggestions or tips I would leave to hear; you can leave a comment below.

2 Comments

  1. Carla on 15th October 2016 at 9:04 pm

    This article is really interesting. I have bookmarked it.
    Do you allow guest posting on your blog ?
    I can write hi quality articles for you. Let me know.



    • david on 16th October 2016 at 10:06 pm

      Hi Carla, glad you liked the article. I must admit I had not really considered guest posting. I’ll give it some thought. I wonder if you could provide me with a link to a post which you have already done or email it to me at david@wisdomwhale.co.uk. I’ll get back to you via email. Cheers.



Scroll Up