try_files php

Marcos Neves marcos.neves at gmail.com
Thu May 27 22:35:06 MSD 2010


Sorry, I forget to say that php is working.
I create a file named phpinfo.php
if I access /phpinfo.php works like always before,
but if I try /phpinfo it shows the source code.

Marcos Neves
+55 44 9918-8488



On Thu, May 27, 2010 at 3:27 PM, Michael Shadle <mike503 at gmail.com> wrote:
> sounds like you just need a php location? this works like a charm.
>
> server {
>        listen 80;
>        server_name foo.com;
>        index index.php index.html;
>        root /home/foo/web/foo.com;
>        include /etc/nginx/defaults.conf;
>        include /etc/nginx/expires.conf;
>        try_files $uri $uri/ /wordpress/index.php?q=$uri;
>        location ~ \.php$ {
>                fastcgi_pass 127.0.0.1:11000;
>                include /etc/nginx/fastcgi.conf;
>        }
> }
>
> On Thu, May 27, 2010 at 11:13 AM, Marcos Neves <marcos.neves at gmail.com> wrote:
>> How can I reproduce this behavior:
>>
>> with a request to /foo/bar
>>
>> try file: foo/bar
>> try index.htm: foo/bar/
>> try file: foo/bar.htm
>> try file: foo/bar.html
>> try parse php: foo/bar.php
>> try file: /layout.htm
>> try file: /layout.html
>> try parse php: /layout.php
>> return 404 if not found.
>>
>> I try this:
>>
>>    location / {
>>      try_files $uri $uri/ $uri.htm $uri.html $uri.php layout.htm
>> /layout.html /layout.php;
>>    }
>>
>> Everything works, except PHP that returns as text file showing the source code.
>>
>> ps: Is there a blog post that explain exactly how location, if,
>> rewrite and try_files works?
>> The docs are not so clear about how the flow works.
>>
>> Marcos Neves
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://nginx.org/mailman/listinfo/nginx
>>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



More information about the nginx mailing list