Setup notes: nginx + wordpress multi site

Substitute

  • domain_name1.com: Your domain name
  • extra_domain_name.com: Extra domains if your also using extra domain mapping in wordpress
  • file_root: Path to your wordpress install

Files

/etc/nginx/sites-available/domain_name1.com

# WordPress Multi Site Domain
server {
    listen 80 ;
    server_name .domain_name1.com .extra_domain_name.com;

    root /file_root/wordpress;
    index index.php index.html index.htm;

    # Rewrite for multi site files
    rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;

    # Rewrite for wordpress
    if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q=$1 last;
    }

    location ~ .php$ {
        fastcgi_pass    unix:/tmp/php-fastcgi.socket; # or port like 127.0.0.1:9000
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }
}

Finish

sudo ln -s /etc/nginx/sites-available/domain_name.com /etc/nginx/sites-enabled/domain_name.com
sudo service nginx restart
This entry was posted in Server, Uncategorized. Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.

4 Comments

  1. Joe Malik
    October 27, 2011 1:12 am

    Hey, that definately saved my day! Thx!

    • October 27, 2011 8:26 am

      Thanks mate! Kind words always appreciated.

  2. May 7, 2012 1:11 am

    Hi,

    Thanks for this. Will it work with sub-domains and directories in a WordPress network?

    Thanks,

    Joe

    • May 7, 2012 12:00 pm

      Hi Joe, I don’t know what changes would be required for a sub-directory setup. I’ve only every employed the sub-domain setup. I know the instructions are a bit terse and probably designed for people who already have nginx / php experience but if you have any trouble setting up a sub-domain install feel free to post more questions.