Run Multiple WordPress Sites on Sub Domains with Single Server

Multiple WordPress Installations on Sub Domains

When it comes to blogging, lot many of us will choose WordPress as a blogging platform because of it’s versatility and ease of use. But when the WordPress platform is self managed (i.e. hosted and installed WordPress manually on server), there can be
many complications related to installations, domain mapping, and managing .htaccess files specially when there are multiple WordPress installations on same server. So, this post will help to setup sub-domain mapping to multiple WordPress installations
on single server.

There are many ways for achieving this functionality like using  .htacess file or using apache2 hosts configurations. In this post we will see the best option where we will Run Multiple WordPress Sites on Sub Domains using apache2 host configuration.
Whenever request comes to server, it will first go to Apache2 and then to .htaccess, if you use .htaccess, it will consume some microseconds and might delay server response. So it’s better to map subdomain requests in apache2 configuration itself.

Note: This is not equivalent to redirecting http://www.example.com/post1 to http://www.example.com/post1-actual. You can use redirection plugin for that purpose.

Resources used:

Instructions file View
Image file View
GoDaddy configurations file View

Prerequisite

1. You must be using Apache2 as server.
2. You need to have root access to your server so that we can make changes to apache2 configuration files.
3. You must have setup subdomain to point to server IP address.
Please check video for more details.

1. Login to Server using SSH and Enable rewrite module:

You can login into the server using SSH, with user having root access so that user can run sudo commands. Execute below command:

2.find apache2 virtual host configuration file:

Next step is to find the Apache2 virtual host configuration file. Note down the location for further steps. For Ubuntu 16.04 with Apache2 below will be default location:

3. Edit default virtual host file : 000-default.conf:

This file is present at location we have found for apache2 virtual host configuration. Execute below command to open file using nano editor:

3. Modify 000-default.conf

Modify the content for tag
, as below:

4.Restart apache2 server and Done!!

Execute below command to restart apache2 server.

You have mapped test1 sub-domain to test1 sub-directory

5. Now map test2 sub-domain to test2 folder:

  • 1. Navigate to nano /etc/apache2/sites-available/
  • copy 000-default.conf as test2.conf
  • Edit test2.conf file
  • Then add the following code to virtual host definition:

    6. Run below command :

    Execute below command:

    7. Restart server, Done!!

    Execute below command:

    You have mapped test2 sub-domain to test2 sub-directory

    So, this is how you can map two separate WordPress installations to different domains.

    Help others by sharing the content!

    Leave a Comment

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