How to Set Up Multiple WordPress Sites on a Single Ubuntu VPS

Feb 17,2021 by Nishant Nath

Posted by Taiba Fatima

Before we discuss on the intricacies of installing multiple sites on a single VPS, lets us understand in brief the technical aspects of WordPress

Multiple WordPress Sites on a Single Ubuntu VPS

CMS: WordPress

WordPress is a well-recognized CMS platform that allows user to create business website and blog.  It enables building different websites, which further can be swiftly hosted on a single VPS (Virtual Private Server) instance. Consider an example, you have two Word Press website, each have their own domain names (e.g. primarysite.com and secondarysite.com). These two sites will run under the single Ubuntu 12.04 VPS server environment.

Set up requirements

This simple guide constitutes a requirement set before you begin the procedure of running two or more sites on one VPS.

At this instance, you should have pre-installed LAMP on the Ubuntu server and both of your domain names should be pointing to that instance.     

Download WordPress

Once you have done with the above steps, log in to your hosting account and follow the below mentioned simple steps.
The web host will download the files here:
Unzip the archive files by executing the following command:

Next step is to create the website databases and the respective users. It will ensure that the website database is separate. 

The above description with the proper commands will give you an idea about creating a database. Substitute your own information while creating the database for your website.

Complete this procedure by granting privileges to the new users. It will associate the database users with their respective databases and grant them permission to perform requisite actions.

Related Topic:  AdSense WordPress Plugins You Can Use to Increase Your Earnings

Configuring the website root directories

In this section, you will know how to install both the WordPress websites within individual directories in the webroot of your hosting server.

After that, create a directory for each of the sites. These directories will store the site files as:
Copy the sample configuration before moving to the web contents into the folders located on your hosted server:

At the end, copy the files to the directories which you have created under the web root of the server:

Allow access of the directories to the Apache web user and thereafter add your Linux username to the web group:

WordPress Configuration

Now let’s move to another section…

Here you will get to know how to configure a WordPress website:

First website configuration

Change the directories to the first’s site document root by following this command:

cd /var/www/PrimarySite

Open the WordPress configuration file for editing:

After setting the database and username for the PrimarySite, save and exit;

Second website configuration

Change the directories to the secondary site document root by executing the following command:

Open the WordPress configuration file for editing:

Once you are done with the website configuration including username and database for the SecondarySite, save and exit;

Setting up the Apache Virtual Host Configuration

Now you must be thing what’s the need to setup an Apache Web Server? So, here we go…

The need to configure Apache web server is that you can direct the traffic from each domain to their respective directories. You can do this by creating separate virtual host files for each domain.
 
Change the directory to Apache’s available sites directory:

Now, create a new virtual host file for each site by copying the default virtual host file by using the following commands:

Creating PrimarySite Virtual Host Configuration   Open the first file that you copied to configure the virtual host for the primary site

Related Topic:  Power Your WordPress Hosting With A Shared Server

Now follow this code snippet to change the information in the file. Make sure to substitute the information in blue to match your primary site.

In case, you need to enable the permalink, you can change the “AllowOverride None” within the “” block to “AllowOverride All”. Once, you have done with the changes, save and close the file.     

Creating SecondarySite Virtual Host Configuration  

Open the second file you copied to configure the virtual host for the secondary site

Now follow this code snippet to change the information in the file. Make sure to substitute the information in red to match your primary site.

After finishing this, save and close the file.

To complete the final configuration, there are few more steps which are necessary to get your WordPress website working. WordPress website needs extra php module to get installed to function impeccably. Use the following code
Next thing to do is enabling the virtual host files that you have created above by coding:

At the end, refresh the apache web server to reflect the changes:

To see your new wordPress websites, navigate to either primarysite.com or secondarysite.com in a web browser. If you have configured correctly, you will see the following WordPress installation page.

Now, you can log in and configure each site individually. These two websites can be administrated separately as they exists on two entirely different VPS servers.

votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Have questions?

Ask us.



    AWS Standard Consulting Partner

    • Go4hosting
    • Go4hosting

    Alibaba Cloud

    Go4hosting

    Go4hosting-NOW-NASSCOM-Member Drupal Reseller Hosting Partner

    Cyfuture Ltd.

    The Cricket Barn
    Tiverton
    Exeter
    EX16 8ND

    Ph:   1-888-795-2770
    E-mail:   [email protected]