Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having a little trouble. I followed the tutorials step by step at rtcamp.com for wordpress multisite, only changing the ‘example.com’ to my domain name. I have the nginx helper plugin installed and it looks like the whole site and everything works great. (It’s a network of about 40 sites moved from a LAMP setup)

I’m having an issue though. Even with the configuration using the fastcgi_cache, my page load time is extremely high. This is what it reads when I view the source code timestamp:

<!--Cached using Nginx-Helper on 2013-03-12 00:21:19. It took 62 queries executed in 13.000 seconds.
Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details -->

This doesn't happen with the root site, only with the sub-directory sites.

Here are my configs: This is the sites-available/example.com

#move next 3 lines to /etc/nginx/nginx.conf if you want to use fastcgi_cache across many sites 
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:500m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;

server {
    #@DM - uncomment following line for domain mapping or you will need to add every mapped-domain to server_name list 
    #listen 80 default_server;
    server_name example.com *.example.com ;
    #@DM - uncomment following line for domain mapping
    #server_name_in_redirect off;

    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 index.html index.htm;

    #fastcgi_cache start
    set $skip_cache 0;

    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
    }   
    if ($query_string != "") {
        set $skip_cache 1;
    }   

    # Don't cache uris containing the following segments
    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $skip_cache 1;
    }   

    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }

        if (!-e $request_filename) {
                rewrite /wp-admin$ $scheme://$host$uri/ permanent;
                rewrite ^(/[^/]+)?(/wp-.*) $2 last;
                rewrite ^/[^/]+(/.*.php)$ $1 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;
    #   fastcgi_pass 127.0.0.1:9000;
        fastcgi_cache_bypass $skip_cache;
            fastcgi_no_cache $skip_cache;

        fastcgi_cache WORDPRESS;
        fastcgi_cache_valid  60m;
    }

    location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
    }   

    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 = /robots.txt { access_log off; log_not_found off; }
#   location ~ /. { deny  all; access_log off; log_not_found off; }

##SITEMAP ABILTIES
    rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
    rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

}

And my nginx.conf:

user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ## Block spammers and other unwanted visitors  ##
    include blockips.conf;


    #FastCGI
    fastcgi_intercept_errors on;
    fastcgi_ignore_client_abort on;
    fastcgi_buffers 8 32k;
    fastcgi_buffer_size 64k;
    fastcgi_read_timeout 120;
    fastcgi_index  index.php;

    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;



    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
# 
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

Help with this problem would be highly appreciated! :)

share|improve this question

1 Answer 1

How do you establish is slow ? Did you enable any sort of limits into php-fpm ? Send the log files from php-fpm and nginx.

share|improve this answer
    
Well I consider it slow because it's taking upward of 13 seconds to load the page. I haven't changed anything in the php-fpm settings. I'm still learning this part of everything, and the tutorial I used didn't mention any changes to the php-fpm config. What sort of changes can I make? Here is the php5-fpm.log: –  Michael Chase Mar 13 '13 at 2:39
    
Here is the php5-fpm.log: [12-Mar-2013 02:40:30] NOTICE: fpm is running, pid 15715 [12-Mar-2013 02:40:30] NOTICE: ready to handle connections [12-Mar-2013 02:53:05] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it [12-Mar-2013 03:06:22] NOTICE: Finishing ... [12-Mar-2013 03:06:22] NOTICE: exiting, bye-bye! –  Michael Chase Mar 13 '13 at 2:46
    
And there are several entries like this in the Nginx error log: 2013/03/12 02:46:27 [error] 15735#0: *4804 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 102.94.37.89, server: example.com, request: "POST /toysandgames/wp-cron.php?doing_wp_cron=1363070786.9193959236145019531250 HTTP/1.0", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com" –  Michael Chase Mar 13 '13 at 3:13
    
And in the nginx access log there are LOTS of these: 174.129.102.11 - - [12/Mar/2013:23:02:35 -0400] "-" 400 0 "-" "-" However I have that ip address blocked in iptables... so I thought, I'll double check that. –  Michael Chase Mar 13 '13 at 3:16

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.