Multiple Drupal Sites on Single ThetaJoin Server

ThetaJoin servers support having multiple Drupal websites on the same server. There are several limiting factors in how many Drupal sites a given server can support. Factors include the combined size of all Drupal MySQL databases, how many page views per second all of the sites experience, and disk space for Drupal site files.

Drupal provides the ability to host several Drupal sites using the same Drupal codebase, or you can have your ThetaJoin hosted Drupal sites use separate Drupal codebases. There are pros & cons to each approach so this chapter will discuss both.

There are several steps to host multiple Drupal sites on the same ThetaJoin server. Namely, create a separate MySQL Drupal database for each site, create a separate Drupal directory in Webmin, configure the webserver for virtual domains using phpMyAdmin & Webmin.

Virtual domains is a way to configure a single webserver to support multiple websites under different domain names. For example, www.thetajoin.com and blog.thetajoin.com websites can be served by a single ThetaJoin server. 

NOTE: It's important when creating virtual domains that the first site document root is always /var/www/drupal. If you change this directory to another name, you'll generate an HTTP 500 server error which locks you out of ALL Drupal sites hosted on your server.

Shared Drupal Codebase - New Site

A shared Drupal codebase environment is slightly easier to configure than the independant Drupal codebase. The steps involved is to install the first Drupal site to your ThetaJoin server, copy & configure site specific Drupal configuration files in /var/www/, then install the new site. You will be required to have DNS configured for your domains. Coordinate with ThetaJoin to have your sites's domain names, and IP addresses configured in DNS.

Install First Drupal Site  

The Installing Drupal chapter of the ThetaJoin Hosting Guide has the directions for installing your first Drupal site. In this example, we'll use site1.thetajoin.com as our first site, or default Drupal site. Site1 should look like:

Hosting Multiple Drupal Sites - Site1

Once site1 is working, create a new directory /drupal/sites/site2.thetajoin.com using Webmin.

Multiple Drupal Sites Create Site2

Using Webmin, copy all files from /drupal/sites/default/* to /drupal/sites/site2.thetajoin.com.

Multiple Drupal Site Hosting Copy Config Files

Using phpMyAdmin, create a new database, we'll call it site2.

Multiple Drupal Site Hosting Create Site2 Database

Next, edit /drupal/sites/site2.thetajoin.com/settings.php file by highlighting settings.php, and clicking the Edit button on the Webmin menu. Scroll to the line that starts with $db_url, and change:

$db_url = 'mysqli://drupaluser:DrupalPassw0rd@localhost/drupal

to

$db_url = 'mysqli://drupaluser:DrupalPassw0rd@localhost/site2

Click on the Save & Close button on the Webmin editor screen.

Multiple Drupal Hosting Editing settings.php File

 

In order to install Drupal for site2, using Webmin, copy /drupal/install.php to /drupal/sites/site2.thetajoin.com/install.php

Multiple Drupal Sites Copy Install File

 

Point your web browser to site2.thetajoin.com, you should see all kinds of errors on the screen. Don't panic, this is because Drupal isn't installed.

Multiple Drupal Sites - Site2 Errors 

Now, point your web browser to site2.thetajoin.com/install.php, and follow the installation instructions just like a single site installation. Your second Drupal site is ready!

Multiple Drupal Site Hosting Completed

 

Independant Drupal Codebase - New Site

 

NOTE: It's important when creating virtual domains that the first site document root is always /var/www/drupal. If you change this directory to another name, you'll generate an HTTP 500 server error which locks you out of ALL Drupal sites hosted on your server.

Independant Drupal codebases is another way to host multiple Drupal websites on your ThetaJoin server. This approach keeps all Drupal related files in separate directories. This is great if you're hosting multiple Drupal sites for different clients, and you can't mix modules, themes, or other customizations between client sites.

Virtual hosting is handled by the webserver, and not by Drupal. This requires some additional configuration steps. The general outline is to upload Drupal into a separate directory, configure the webserver to know about this new Drupal directory, and create the new Drupal MySQL database for this site. The rest of the Drupal installation is just like installing any Drupal website. You can read those directions in the Installing Drupal chapter of the ThetaJoin Hosting Guide.

Your first Drupal website on your ThetaJoin server should already be installed, so we'll just go over adding site2 to an already existing Drupal website. The site1.thetajoin.com website is all located in the drupal directory. The second site will be stored in site2.thetajoin.com directory. Once the Drupal tarball has been uploaded and untarred, rename the drupal-6.xx directory to site2.thetajoin.com. You can use Installing Drupal chapter to install site2 as well. Webmin should look like this:

Multiple Drupal Hosting Separate Codebase

Next, we need to tell the webserver that there's another copy of Drupal in the site2.thetajoin.com directory, and create another Drupal MySQL database for site2. Login to phpMyAdmin on your ThetaJoin server, create the virtual host by selecting the VirtualHosts database from the left menu, then click on the insert button Insert Button in the Drupal table row. When the insert page displays - In the domainname row, value column, enter site2.thetajoin.com. In the drupaldocumentroot row, value column add /var/www.site2.thetajoin.com. Click the Go button. Be sure to replace site2.thetajoin.com with your real Drupal site domain name! Your virtual host setting should look something like this:

Multiple Drupal Sites Create Virtual Hosts

After clicking the Go button:

Multiple Drupal Hosting Create Virtual Hosts Results

The webserver on your ThetaJoin server is now aware of the site2.thetajoin.com Drupal site. With ThetaJoin servers, there's no need to restart the webserver, any virtual hosts created are automatically configured. This means already installed Drupal websites will not see any downtime. (If you keep your first Drupal site in the /var/www/drupal directory!)

Point your web browser to your second Drupal site, you should be brought to the installation page for site2! The rest of the installation is just like installing any other Drupal site. You can follow the rest of the Drupal installation instructions in the Install Drupal chapter of the ThetaJoin Hosting Guide.

 

Moving Multiple Existing Drupal Sites into Single ThetaJoin Server 

With the high performance of ThetaJoin servers, it's possible to move multiple existing Drupal sites from existing multiple generic hosting company servers. The best way to move your already existing Drupal websites is by using the directions in the Independant Drupal Codebase instructions combined with the instructions from the Moving Drupal from Another Server chapter in the Drupal Hosting Guide. The general steps are:

  1. Backup up the Drupal MySQL database from your existing generic hosting server.
  2. Restore the Drupal MySQL database into your new ThetaJoin server. If more than one site is already installed on your ThetaJoin server, verify that the newly moved Drupal MySQL database name doesn't conflict. If you need to change the name of the Drupal database, you'll need to change the $db_url line in site/www.example.com/settings.php as described above in the Shared Drupal Codebase section.
  3. Create tar.gz or tgz file of your existing Drupal site files in your generic hosting server web directory.
  4. Upload and untar/unzip you existing Drupal site files into your new ThetaJoin server.
  5. Rename this directory to your Drupal site's domain name: www.example.com
  6. Create a Virtual Host in your new ThetaJoin server as described above in the Independant Codebase section. As an example, the domainname value would be www.example.com, drupaldocumentroot would be /var/www/www.example.com.
  7. Notify ThetaJoin via email that you'd like your DNS configured for your this newly moved website. Since ThetaJoin will be handling DNS for your website, and email, please follow the directions in the DNS Configuration for ThetaJoin Servers.