Mastering Nginx

(Ron) #1

The NGINX HTTP Server


[ 146 ]

An example Drupal configuration


Drupal (http://drupal.org) is a popular open source content management platform.


There is a large installed user base, and many popular websites are run on Drupal.
As with most PHP web frameworks, Drupal is typically run under Apache using


mod_php. We are going to explore how to configure NGINX to run Drupal.


There is a very comprehensive Drupal configuration guide for NGINX found at


https://github.com/perusio/drupal-with-nginx. It goes more in-depth than
we are able to do here, but we will point out some features mentioned, and go


through some of the differences between Drupal 6 and Drupal 7:


## Defines the $no_slash_uri variable for drupal 6.
map $uri $no_slash_uri {

~^/(?<no_slash>.*)$ $no_slash;
}

server {

server_name http://www.example.com;

root /home/customer/html;

index index.php;

# keep alive to the FastCGI upstream (used in conjunction with
# the "keepalive" directive in the upstream section)
fastcgi_keep_conn on;

# The 'default' location.
location / {
## (Drupal 6) Use index.html whenever there's no index.php.
location = / {
error_page 404 =200 /index.html;
}
# Regular private file serving (i.e. handled by Drupal).
location ^~ /system/files/ {

include fastcgi_private_files.conf;

fastcgi_pass 127.0.0.1:9000;
Free download pdf