# Try\_files setup

**URL:** <https://www.ruby-forum.com/t/try-files-setup/242642>\
**Category:** NGINX\
**Created:** [July 10, 2015, 5:16pm UTC](https://www.ruby-forum.com/t/try-files-setup/242642 "2015-07-10T17:16:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [July 10, 2015, 5:16pm UTC](https://www.ruby-forum.com/t/try-files-setup/242642/1 "2015-07-10T17:16:58Z")

</div>

Hello,

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

I’m currently working on a nginx + php5-fpm (chrooted) + wordpress  
setup.  
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/](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\_pass 127.0.0.1:1234;  
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](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. 🙂

–

Best regards,  
Artur.

---

<div class="post-metadata">

**Author:** ![Artur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/53a042/32.png) [@Artur](https://www.ruby-forum.com/u/Artur)\
**Post date:** [July 17, 2015, 5:40pm UTC](https://www.ruby-forum.com/t/try-files-setup/242642/2 "2015-07-17T17:40:59Z")

</div>

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

–

Best regards,  
Artur.

---

<div class="post-metadata">

**Author:** ![Artur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/53a042/32.png) [@Artur](https://www.ruby-forum.com/u/Artur)\
**Post date:** [July 17, 2015, 6:21pm UTC](https://www.ruby-forum.com/t/try-files-setup/242642/3 "2015-07-17T18:21:53Z")

</div>

Add this to the php location

try\_files $uri =404;

## Melhores Cumprimentos // Best Regards

Miguel C.  
IT - Sys Admin & Developer
