Contents of Table
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
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.
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.
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.
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:
Now let’s move to another section…
Here you will get to know how to configure a WordPress website:
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;
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;
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
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.
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.