A
A
Arman2013-06-20 16:03:31
PHP
Arman, 2013-06-20 16:03:31

nginx + php-fpm setup: folder exists and index.php exists

the site works on apache, the task is to transfer it to a bunch of nginx + php-fpm.

There is a config:

        location / {
                index index.php

                if (!-e $request_filename) {
                     rewrite ^/(.*)$ /index.php?$args last;
                     break;
                }
        }


If the file, folder and char. links are thrown to php-fpm.

Broken URLs that end in "/"

/forum/styles.css - works, the file exists returns nginx
/forum/news.html - works, the file does not exist, generates php-fpm (/index.php)
/forum/index. php - works, the file does not exist, generates php-fpm (/index.php)

/forum/ - does not work, nginx sees that the folder exists and does not return it php-fpm (/index.php) = 403 Forbidden.

I tried to do it through "!-f ", it seems to work, but it breaks in another place:

there is a path
/xhprof_html/index.php?a=1&b=2
/xhprof_html/index.php - exists!

doesn't work like this
/xhprof_html/?a=1&b=2

i.e. can't see index.


Thanks in advance

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Puma Thailand, 2013-06-20
@Arik

everything has long been done through try files
bad example
location ~ \.php$ {
<------> try_files $uri =404;
fastcgi_pass unix:/opt/pifpm/fpmsockets/fashions.sock;
fastcgi_index index.php;
include fastcgi_params;

A
Aleksandr Kuznetsov, 2013-06-22
@x_T

you need to add one more match condition for try_files - $uri/

        index index.php index.html index.htm;
        location / {
                try_files $uri $uri/ @rewrite;
        }

        location @rewrite {
                rewrite ^ /index.php?$args;
        }

E
EugeneOZ, 2013-06-20
@EugeneOZ

Drupal itself is not a sample, but this article may help you:
wiki.nginx.org/Drupal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question