Wordpress have a blank screen when i use nginx cache config

Hi Group!

I try to use nginx configuration described in this post.

http://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/

This is my nginx config

user www www;

worker_processes 8;

events {
worker_connections 2048;
use kqueue;
}

http {

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

sendfile on;

fastcgi_cache_path /var/tmp/nginx/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 {
listen 188.40.73.XXX:80;
server_name .site.com;

access_log   /var/log/newexp-access.log;                                                                                                                                                                         
error_log    /var/log/newexp-error.log debug;                                                                                                                                                                   

root /usr/local/www/data/www.site.com;                                                                                                                                                                     
index index.php;                                                                                                                                                                                                 

if ($host = 'site.com') {
rewrite ^(.*)$ http://www.site.com$1 permanent;
}

rewrite ^(/forums/)(.*)$ http://forum.site.com/$2 permanent;

rewrite ^/plugins/p47_rsssyn/(.*)$ /?feed=rss permanent;

rewrite ^/plugins/p2_news/(.*)$ /news permanent;

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_-]+-sitema  
    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;                                                                                                                                                                                          
}     

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

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

    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; }                                                                                                                                                

}

}

but when i apply this config i see only blank screen and errors like this in my log

root@mx1/usr/local/etc/nginx> nginx -t nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

root@mx1/usr/local/etc/nginx> ls -lhad /var/tmp/nginx/nginx-cache/ drwx------ 18 www www 512B 12 июн 15:32 /var/tmp/nginx/nginx-cache/ root@mx1/usr/local/etc/nginx>

PID PPID USER %CPU VSZ WCHAN COMMAND 63225 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63226 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63227 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63228 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63229 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63230 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63231 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63232 89212 www 0,0 537048 kqread nginx: worker process (nginx) 63233 89212 www 0,0 537048 kqread nginx: cache manager process (nginx) 63234 89212 www 0,0 537048 kqread nginx: cache loader process (nginx) 89212 1 root 0,0 537048 pause nginx: master process /usr/local/sbin/nginx 63611 42537 root 0,0 2484 vnread egrep (nginx|PID) root@mx1/usr/local/etc/nginx>

root@mx1/usr/local/etc/nginx> du -h /var/tmp/nginx/nginx-cache/ 4,0k /var/tmp/nginx/nginx-cache/4/fd 4,0k /var/tmp/nginx/nginx-cache/4/f5 4,0k /var/tmp/nginx/nginx-cache/4/c0 4,0k /var/tmp/nginx/nginx-cache/4/47 4,0k /var/tmp/nginx/nginx-cache/4/53 4,0k /var/tmp/nginx/nginx-cache/4/09 26k /var/tmp/nginx/nginx-cache/4 4,0k /var/tmp/nginx/nginx-cache/9/de 4,0k /var/tmp/nginx/nginx-cache/9/7c 4, . . 4,0k /var/tmp/nginx/nginx-cache/a/0d 22k /var/tmp/nginx/nginx-cache/a 558k /var/tmp/nginx/nginx-cache/ root@mx1/usr/local/etc/nginx>

but in browser i see only blank screen :(

this is my error log file

013/06/12 21:40:10 [notice] 54169#0: 3749103 "^/plugins/p47_rsssyn/(.)$" does not match “/includes/vvc.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "^/plugins/p2_news/(.)$" does not match “/includes/vvc.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "(/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)" does not match “/includes/vvc.php?vvcid=31330757”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: *3749103 “comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in” does not match “”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "^(/forums/)(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "^/plugins/p47_rsssyn/(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "^/plugins/p2_news/(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: 3749103 "(/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)" does not match “/includes/vvc.php?vvcid=31330757”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [notice] 54169#0: *3749103 “comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in” does not match “”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31330757 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:10 [info] 54169#0: *3749103 kevent() reported that client 141.8.147.10 closed keepalive connection
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^(/forums/)(.)$" does not match “/includes/vvc.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^/plugins/p47_rsssyn/(.)$" does not match “/includes/vvc.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^/plugins/p2_news/(.)$" does not match “/includes/vvc.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "(/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)" does not match “/includes/vvc.php?vvcid=31287520”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: *3749121 “comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in” does not match “”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^(/forums/)(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^/plugins/p47_rsssyn/(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "^/plugins/p2_news/(.)$" does not match “/index.php”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: 3749121 "(/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)" does not match “/includes/vvc.php?vvcid=31287520”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 21:40:12 [notice] 54169#0: *3749121 “comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in” does not match “”, client: 141.8.147.10, server: site.com, request: “GET /includes/vvc.php?vvcid=31287520 HTTP/1.1”, host: “www.site.com
2013/06/12 2

this is log file
http://pastebin.com/r8s18ahq

Thank you! I hope you help me!

I checked log file and its incomplete.

After so many lines containing “does not match”, there must be a line containing “using” in error log.

That line tell us which config Nginx uses for requested URL. Most likely it is not picking correct location. Try to find that “using” line and portion below it. I may be able to solve your problem after analysing that portion. :slight_smile:

Hi Rahul!
I wait more than 30 min but not one record with “using” line in my error log file :frowning:

may be possible use another test method?

for example i try to find cache file
screenshot

put this url in my browser

http://http://www.site.com/news/p2_articleid/18726

have a blank screen and nothing with “using” in my error log

but have

First, check error_log level. It must be debug Not notice.

With debug, level, for a request you will get around 100 lines of output.

Please paste that debug-level log on pastbin.

i use debug mode.
error_log /var/log/newexp-error.log debug;

Try restarting nginx, clearing log files.

Debug-level logs don’t look like this - http://pastebin.com/wyYxAkRC
Its notice level log.

Good day Rahul!
How to send error log with debug to you? It’s to large …
and i d’t know what info do you need to quote it.

this is part of log file
http://pastebin.com/7H5jG8yU

You can upload files here. There is “Attachments:” option above “Submit” button.

Please send only relevant part.

Here is how to go about it:

  1. Clean Error Log File
  2. From another terminal/command-line run: curl http://example.com/URL
  3. Paste URL used in your reply.
  4. Paste outcome - if URL is changed, which URL you got redirected to, etc
  5. Attach log file using “Attachments” option below reply-box.

Your pastbin log is good enough in volume but it is generated for homepage requests. See line#21 for request: “GET / HTTP/1.1”

this was a private reply with post_id 40158

root@mx1/usr/home/vvs>  

root@mx1/usr/home/vvs> rm -rf /var/log/newexp-error.log root@mx1/usr/home/vvs> ngrl Performing sanity check on nginx configuration: nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful root@mx1/usr/home/vvs> Date: Mon, 17 Jun 2013 12:08:50 GMT Content-Type: text/html Connection: keep-alive

root@mx1/usr/ports> curl -I http://www.st.com/news/p2_articleid/18726 HTTP/1.1 200 OK Server: nginx/1.4.1 Date: Mon, 17 Jun 2013 12:08:52 GMT Content-Type: text/html Connection: keep-alive

root@mx1/usr/ports> curl -I http://www.st.com/news/p2_articleid/18726 HTTP/1.1 200 OK Server: nginx/1.4.1 Date: Mon, 17 Jun 2013 12:08:53 GMT Content-Type: text/html Connection: keep-alive

Sorry. I cannot see any attachment with your private reply.

Please attach again.

i make new attach. do you see it? may be attach size too small?

I checked your log files and didn't find anything unusual at nginx end.

It looks like php is returning empty output.

Also, curl -I will generate HEAD request. Always use curl -X GET to create HTTP GET request.

Can you take backup of your current config and use config presented here - http://rtcamp.com/wordpress-nginx/tutorials/single-site/minimal/ ?

Lets see if WordPress works without caching first. Then add your extra rewrite rules. If pages which were showing earlier blank output shows correct output, then issue is with caching part.

Good day Rahul! When i use minimal config i got a blank screen :( this is debug log http://pastebin.com/ZTq0c4fb

when i add line fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

in my location ~ .php$ {

and it' look like

location ~ .php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

everything is ok

There is no problem in adding:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

You can add it in previous config. In fact, you can add that line in fastcgi_params file so it will be added to all PHP block.

I already have such a line in my fastcgi_params file:

fastcgi_param SCRIPT_FILENAME $request_filename;

What version of Nginx you are using. It looks like an old version.

its mystic but when i add this line fastcgi_param SCRIPT_FILENAME $request_filename; in my location ~ .php$ { nginx d't create no one cache file in my /var/nginx path :(

root@mx1/var/nginx> ls -l total 0 root@mx1/var/nginx>

if i remove this line fastcgi_param SCRIPT_FILENAME $request_filename;

cache files creating

root@mx1/var/nginx> ls -l total 12 drwx------ 3 www www 512 21 июн 10:52 0 drwx------ 3 www www 512 21 июн 10:52 2 drwx------ 3 www www 512 21 июн 10:52 b root@mx1/var/nginx>

but i have a blank screen when browse a site %(