How to setup Nginx + PHP-FPM + Drupal 7.0 on Debian Squeeze

January 27, 2013

This post just show how to setup Nginx and PHP-FPM on Debian minimal installation. It's not tweaked for the specific use case or guaranteed high performance, you probably will need configure some details. If you use Ubuntu setup is same (haven't tried, but probably same or similar)

First thing after you have made a clean installation of Debian minimal is to configure Locales.

dpkg -reconfigure locales

Update & upgrade

apt-get update
apt-get upgrade

Adding a new repository (in Debian Nginx is not available in default repository, in Ubuntu it this)

vi /etc/apt/sources.list
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

Adding keys for the repository

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add

Update & upgrade

apt-get update
apt-get upgrade

Install Nginx / PHP-FPM & APC

apt-get install php-apc php-pear php5-cli php5-common php5-curl php5-suhosin php5-fpm php5-gd nginx php5-mysql

Restart Nginx

/etc/init.d/nginx start

Mysql installation (you can also try to install MariaDB instead Mysql)

apt-get install mysql-server mysql-client

PHP-FPM restart

/etc/init.d/php5-fpm restart

Next step is to create Drupal site on this server
define your directory (e.g /var/www)
create Nginx site with configuration

Example Nginx site with custom settings for Drupal is available for you to download at bottom of this post. If you use same location of (/var/www) you only need to change example.com to your domain name (line 3), and remove txt extension on the end. Nginx folder on your server is in this folder /etc/nginx

If you interested more for Drupal running on Nginx, here few links:

Are you thinking switching from Apache to Nginx, if yes you have several things to consider, except better performance which is primary goal, people forget stuff like that htacess is not anymore needed and you need to know at least basics of Nginx, or some modules can break, etc..

So think good and test a lot.

Example nginx config default-54.txt