In the fastcgi + nginx tutorial, the block for PHP is:
location ~ .php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
However, I get blank pages when I do that. In instead of this code, I’m then using something similar to the one in Wordpress Codex Nginx:
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 30d;
}
This is the only way I found out to avoid blank pages and fastcgi_cache seems to be working. The question is: Am I doing a good thing or the change I was forced to do in the code has any negative point?
Thanks.