Install DRUPAL 6/7 Configured for NGINX with Clean URLs: VPS BIBLE




new password?
login
X
Drupal logo

This tutorial shows how to set up the Drupal content management system on Nginx with SEO-friendly pretty links (CURLs, FURLs, whatever they’re called this week).

There have been a host of requests for this guide so here it is. In the next how-to we’ll take this further with the addition of multiple Drupal sites, all powered from the same single Drupal installation.

The procedure now is to create the database and domain zone, edit a new virtual host file with a symlink to Nginx, setup the directory structure, download the Drupal platform, run its installer and tweak the URL and caching options.

Cracking on …

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.

One pre-requisite: throughout this guide I refer to the domain domain.com. Be careful to replace that with yourOwnDomain.tld.

Create the Drupal Database

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

Add a New Domain Zone

Follow Add a Domain Zone to Your VPS.

Create the Drupal Site’s Virtual Host File

This is your site configuration file or vhost, making it play nice with the Nginx web server. Create it using the nano text editor:-


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.


.. pasting this within (replacing the seven instances of domain.com with YOURdomain.tld):-

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.

Nginx Rewrite Syntax for Drupal Clean URLs

In case you were wondering, the code above that gives you the all-important, SEO-friendly CURLs is located in the site root’s location block (.. location / ..):-


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 a Symbolic Link (symlink)

In a more basic Nginx setup we could add a site configuration to the main Nginx config file, nginx.conf. But that can get pretty messy, especially when we have a bunch of sites to administer. Instead, therefore, we create individual site configuration files – better known as virtual host files or vhosts – as we’ve done above. Then we link these to the nginx.conf file by way of a kind of shortcut – better known as a symbolic link or symlink. So now you know.

Let’s create a symlink for this Drupal 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.

Restart Nginx

And restart the web server so that it recognises our changes:-


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.

Download Drupal into an Nginx-Compatable Directory Structure

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


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.

.. giving your password, as prompted.

Now to create the new site’s directory structure:-


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 head to the 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.

Download the latest Drupal release. If it’s not the latest, no worries, you can upgrade from within the Drupal application once it’s set up. Or check for the latest here. Retrieve the zipped file like so:-


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.

I’m using Drupal 7 here but this Nginx connection works equally well with Drupal 6.

.. and unzip it:-


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.

.. removing the zipped file:-


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.

Change the name of the unzipped Drupal folder to public (the root web folder):-


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.

Prepare Drupal’s Settings.php File

Among other things, Drupal’s settings.php file provides your MySQL database details to the platform.

Firstly, we’ll copy it from default.settings.php, leaving the original intact:-


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 set some temporary 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.

And give Nginx access to Drupal’s settings file and the complete directory structure:-


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

In a browser, surf to http://domain.com

Following the prompts, here’s a summary of what’s required ..

Standard Install with commonly used features pre-configured. Most will want this.

Minimal Start with only a few modules enabled. If you know Drupal well and want to choose your own content types, choose this.

Click Save and Continue.

Choose Language This screen offers English. Want more choices? Read this.

Click Save and Continue.

Database Configuration Add your MySQL database details.

.. you’ll need the new db name, your username and password.

Click Save and Continue.

Revert Temporary Permissions

Don’t omit 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.

Configure Site

Add some site information, an administrator name (Security Tip: don’t use ‘admin’!) and password and locale settings. Pretty straightforward stuff.

Click Save and Continue.

Start Drupal’s Clean URLs

We already did the donkey work with that simple rewrite rule in the virtual host. Now we’ll enable that. Goto:-


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.

.. ensure Enable Clean URLs is checked and click Save Configuration.

Setup Drupal Caching

Goto:-


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 under Caching, check Normal (recommended) and Save Configuration.

There are plenty more options to look at but that’s the key stuff for Drupal with Nginx. If you’re after the procedure for setting up multiple sites (individual domains) on Nginx, all working from the same Drupal installation, like I said above, it’ll be published a couple of days after this post.

Have fun!

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.