Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

A little background: We've decided to abandon Apache because it can't keep up with the demand we're putting on it. We have a cron script that will create a new post about once every 3 or 4 seconds containing a product. This puts a huge memory strain on the system, and even the top VPS option with Godaddy can't handle it. We've decided to not only abandon Apache, but start fresh and move everything to a cloud solution using profitbricks.com.

One of the first steps was to decide on a webserver, and we found nginx. Nginx has a lot of positive reviews, and has a growing userbase. I was able to set everything up and get it working on the new server. The posts were created at a rate of one/3seconds, main site was snappy, and not even a performance blip with the server. The trouble was that all of the sub-directory sites took minutes to load. Not acceptable.

Now I'm looking into Cherokee as the webserver. And having another issue, the main page is snappy, but this time, the sub-sites won't even load. It gives a 404 error. This tells me the rewrite rules are wrong. (now here's the potential deal breaker with Cherokee...) The only documentation I can find about how to set up WPMS using subdirectories is 3 years old and is way out-dated. I've been on this for a couple weeks now, and I'm starting to feel some pressure, b/c I need to get this website back online ASAP.

So here's my question: Can anybody help me to put together a stable, fast NGINX configuration OR can anyone help me to translate the multisite .htaccess rewrite rules into something that will work with the current stable version of Cherokee?

Please help if you are able. :) -Chase

Here's my current nginx config:

map $uri $blogname{
    ~^(?<blogpath>/[^/]+/)files/(.*)    $blogpath ;
}

map $blogname $blogid{
    default 0;
    #include /var/www/example.com/htdocs/wp-content/plugins/nginx-helper/map.conf;
    #Add list of blogs with their ids. SEE "FILE-HANDLING" SECTION.
    /site1/ 2;
    /site2/ 3;
}
server {
    server_name example.com www.example.com ;

    access_log   /var/log/nginx/example.com.access.log;
    error_log    /var/log/nginx/example.com.error.log;

    root /var/www/example.com/htdocs;
    index index.php;

    location ~ ^/files/(.*)$ {
          try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
          access_log off; log_not_found off; expires max;
    }

    #avoid php readfile()
    location ^~ /blogs.dir {
        internal;
        alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
        access_log off; log_not_found off;  expires max;
    }

    if (!-e $request_filename) {
        # wp-admin to wp-admin/
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;  
        #other wp-* files/folders
        rewrite ^(/[^/]+)?(/wp-.*) $2 last; 
        #other php files
        rewrite ^(/[^/]+)?(/.*\.php) $2 last; 
    }

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }

    location ~ \.php$ {
        try_files $uri /index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off; log_not_found off; expires max;
    }

    location = /favicon.php { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }
    location ~ /\. { deny  all; access_log off; log_not_found off; }
}

And a layout of the rules I found for Cherokee:

1 - Rule Type: Regular Expression: Rule:

    Regular Expression: ^/.*files.*$

Handler:

    Redirection - Regular Expression: ^/(.*)files/(.*) to Substitution: /wp-content.php?file=$2

2 - Rule Type: Complex: Rule:

    Regular Expression: ^/([_0-9a-zA-Z-]+)/(wp-.*|.*\.php(\?.*|))$ AND
    Not ( File Exists, Match any file, disabled all the other checkboxes )

Handler: Redirection, 2 lines:

    Type Internal, Regular Expression: ^/([_0-9a-zA-Z-]+)/(wp-.*)$ to Substitution: /$2
    Type Internal, Regular Expression: ^/([_0-9a-zA-Z-]+)/(.*\.php(\?.*|))$ to Substitution: /$2

3 - Rule Type: Regular Expression: Rule:

    Regular Expression: ^/(.*)\.php(\?.*|)$

Handler:

    FastCGI, Information source: PHP Interpreter. All options left as default.

4 - Rule Type: Complex Rule:

    Regular Expression: ^(.*)$ AND
    NOT ( File Exists, Match any file, disabled all the other checkboxes )

Handler:

    Redirection: Internal, Regular Expression: ^/(.*)$ to Substitution: /index.php

Thanks so much for any help!

share|improve this question
    
Interesting problem... (+1). By default I'd say it's off topic, but on the other this problem so far just haven't been here, so I vote for not closing. Only hint I can give you: Search on GitHub. You might have a good chance to catch something there. –  kaiser Mar 8 '13 at 1:29
    
Thanks kaiser. This is kickin my butt lately. I looked on Github and google code this last week, I'll definitely dig some more. Thanks –  Michael Chase Mar 8 '13 at 4:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.