Setting up wordpress multisite on nginx with php-fpm on debian

Here’s how to setup the nginx and wordpress multisite combo for a network of blogs across different domains on Debian Squeeze. This will work for a standalone host or a VPS.

1. Add sources for latest nginx and php using nginx and dotdeb repositories. Add these to /etc/apt/sources.list

deb squeeze nginx
deb-src squeeze nginx
deb squeeze-php54 all
deb-src squeeze-php54 all

2. Add the keys for the repositories

wget && cat dotdeb.gpg | sudo apt-key add -
wget && sudo apt-key add nginx_signing.key

3. Download and install all required packages

sudo apt-get update

sudo apt-get dist-upgrade

sudo apt-get install php5-mysql php5-gd php5-fpm php5 php-apc nginx mysql-client mysql-server

4. Setup nginx

For master site ( edit /etc/nginx/sites-available/, for all other sites leave root as it is but change the dir for the logs.

server {
listen   80; ## listen for ipv4
access_log  /var/www/;
error_log  /var/www/;
root   /var/www/;
index index.php;
client_max_body_size 20M;
location ~ \.php$ {
fastcgi_pass   unix:/var/run/php5-fpm.sock;
fastcgi_index  index.php;
include        fastcgi_params;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

location = /favicon.ico {
log_not_found off;
access_log off;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;

location / {
try_files $uri $uri/ /index.php;

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;

Symlink your available sites to your enabled sites

sudo ln -s /etc/nginx/sites-{available,enabled}/

5. Download and install wordpress

cd /var/www/ && wget && tar zxf latest.tgz

Use mysql client or phpmyadmin to create a database.

Open your browser point it to your website and follow the wordpress web based installer. Afterwards edit your wp-config.php add these lines after the last define in php.

define('WP_ALLOW_MULTISITE', true);
define( 'SUNRISE', 'on' );

Install the multi domain mapper plugin and use the settings to configure the sites you use.

Any questions, leave a comment.