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 http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx
deb http://packages.dotdeb.org squeeze-php54 all
deb-src http://packages.dotdeb.org squeeze-php54 all

2. Add the keys for the repositories


wget http://www.dotdeb.org/dotdeb.gpg && cat dotdeb.gpg | sudo apt-key add -
wget http://nginx.org/keys/nginx_signing.key && 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 (example.com) edit /etc/nginx/sites-available/example.com, for all other sites leave root as it is but change the dir for the logs.

server {
listen   80; ## listen for ipv4
server_name  example.com;
access_log  /var/www/example.com/logs/access.log;
error_log  /var/www/example.com/logs/error.log;
root   /var/www/example.com/public_html/wordpress;
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}/example.com

5. Download and install wordpress


cd /var/www/example.com/public_html && wget http://wordpress.org/latest.tar.gz && 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.