Setup MULTIPLE SITES on DRUPAL 7 with NGINX & Clean URLs: VPS BIBLE




new password?
login
X
Drupal logo

This tutorial shows how to set up multiple domains all powered by a single Drupal content management system caching on Nginx with SEO-friendly links.

In Setup Drupal on Nginx, Caching with Pretty Links we created our first Drupal site. Now let’s go to town and add a bunch more – ie, thisDomain.com, thatDomain.net, anotherDomain.tld – all fed from the one Drupal installation. Pretty powerful.

The procedure, per site, is: create the database and the domain zone for DNS, the Nginx virtual host file with its symlink, make the web files directory, run Drupal’s installer and tweak the application for the pretty links and caching.

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

  .. from blank box to cute-as server ..  

with this easy-to-follow copy/paste guide.

22+ parts with video, here’s the index.

Notes: However many sites you want, follow Setup Drupal on Nginx, Caching with Pretty Links to set up the first, initial one, then this guide to add the others.

In this tutorial I refer to domain.com – that is my initial site. Also I refer to anotherDomain.com – that is an example of an additional site. Before pasting my code be sure to change domain.com and anotherDomain.com to your website domain names! You probably knew that .. just testin’.

Create the Drupal Databases

Follow Create a MySQL Database from the Terminal/Command Line.

You could use the same database for multiple sites, changing the table prefix for each. Generally though, it’s probably better to keep the databases separate and that’s what I’m recommending (well, in general!). It keeps the process simpler too. So, create one database per site. If you want to, down the road, you can merge dbs easily enough (but that’s another tutorial for another day).

Add a New Domain Zone

Setup a DNS zone for each domain.

Follow Add a Domain Zone to Your VPS.

Multiple Domains on Drupal – The 101

Our root Drupal installation lives here:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Our site access and error logs live here:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

And the actual site files live here:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

So when we add a new site (in this case anotherDomain.com) we add its files to here:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. but it must refer to the root Drupal installation to work, and that’s achieved in each new site’s Nginx virtual host file

.. So, as I say, we configure the above in each site configuration (or virtual host or vhost) file. We may as well do that now then:-

Create A Virtual Host File, Per Drupal Domain

Create the site configuration file that interacts between Nginx and Drupal:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. and paste this within but before pasting make a few replacements (see Virtual Host Replacements just below the code):-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Virtual Host Replacements

Replace:-

  • the three instances of anotherDomain.com with yourADDITIONALdomain.tld
  • access_anotherDomain.log with access_yourADDITIONALdomain.log
  • error_anotherDomain.log with error_yourADDITIONALdomain.log
  • the four instances of domain.com with yourINITIALdomain.tld

Make a Symbolic Link (symlink)

Amend and paste this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Restart Nginx

Make Nginx aware:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Create Web Files Directory Structure

First we’ll assume Super User (or root) permissions:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. providing your password when prompted.

Goto our Drupal sites directory:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Create a directory for each new site:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

We need Drupal’s settings.php file so we can install a new site. Let’s copy it from Drupal’s default site:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Make it editable:-

chmod 777 anotherDomain.com/settings.php

And set permissions to allow Nginx web server access:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Run the Drupal Installer

Using your web browser, head to your extra domain http://anotherDomain.com

Follow the prompts, just as we did in Setup Drupal on Nginx, Caching with Pretty Links.

Revert Temporary Permissions

When you’ve finished with Drupal’s installer, don’t forget to do this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. and exit Super User status (leave root):-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Setup Clean URLs

Enable those super-SEO-savvy links. Surf to:-

http://anotherDomain.com/#overlay=admin/config/search/clean-urls

.. check Enable Clean URLs and Save Configuration.

Setup Drupal’s Caching

Goto:-

http://anotherDomain.com/admin/config/development/performance

.. and under Caching, check Normal (recommended) and Save Configuration.

More Sites?

Rinse and repeat!

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

with this easy-to-follow copy/paste guide.

“My local PC runs Windows” Show me for Linux/Mac

22+ parts with video, here’s the index ..

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Already set it up? We’d best maintain it then.

Toggle to the ..  Ubuntu-Nginx Admin Index

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Maintain your virtual private server with ..

.. cheatsheets, tutorials, tips & guides.

Head back to the ..  Ubuntu-Nginx Installation Index

Nginx Admin: In the Works ..

This lot’s marked for addition already:-

  • Setup or Edit DNS using Bind
  • Network Tools Troubleshooting Guide
  • The Comprehensive Permissions Guide
  • Configuring Nginx Rewrites
  • Custom Website Error Page
  • Setting up Cron Jobs
  • Rsync for Incremental Remote-to-Local Backup
  • Cron & Rsync for Automatic Backup
  • Cron & mysqldump for Auto DB Backup
  • Safeguard Bandwidth with Hotlink Protection
  • Block Access with Nginx’ IP Deny



Got a Question? Want to Comment?

This site has no comments system. We've got a better system!

Please use the link at the top of the post and goto this topic's forum thread:-

  • to help build community
  • for a superior knowledge base
  • to keep info in one place, not diluted between forum & comments.

For those posts ported from Guvnr.com (pre-Feb/2010), archive comments remain.

Handy info from these comments is in the process of being ported to the forum and attributed to the original author.

If you think this idea sucks, let me know.

Thank you.