Try_files setup


I’m quite new to the advanced nginx configuration so I will need your
help. :slight_smile:

I’m currently working on a nginx + php5-fpm (chrooted) + wordpress
My basic setup works fine but I wanted to improve the try_files section.

My main concern is to correctly take in charge URIs by nginx or php5-fpm
depending on their types and existence.

My current setup for wordpress with nice permalinks
(http://host/wordpress_page/) :

location / {
root /content/chroot/htdocs;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;

location ~ .php$ {
include fastcgi_params;
root /htdocs;
fastcgi_param SCRIPT_FILENAME $document_root$request_filename;

error_page  404              /404.html;
#location = /404.html {
# root   /usr/share/nginx/html;

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;

The main problem is that if I try to get a non existing php file
(http://host/nonexisting.php) I get always “No input file specified.”
fpm error.
I’d like to redirect here to a 404 error page instead.

In case I call a different non existing file (nonexisting.jpg) I get an
error displayed from Wordpress saying this page does not exist. I
suppose this is correct in a wordpress setup because of the permalinks
setup I described above.

Any help will be appreciate. :slight_smile:

Best regards,

No one has any idea about the solution for this problem ?

Best regards,

Add this to the php location

try_files $uri =404;

Melhores Cumprimentos // Best Regards

Miguel C.
IT - Sys Admin & Developer