I had to migrate to nginx web server some web application written using Jelix PHP framework and I’ve hard a problem with Jelix URLs that look like http://domain.com/site/script.php/arg1/arg2/arg3. Originally Jelix requires “Options +MultiViews” and “AcceptPathInfo on” in Apache config, neither of which are available on nginx. It took a while to find proper solution.
It turns out that Jelix passes arguments via PathInfo parameter – I have no idea why. Anyway here is the important part of nginx configuration that allows passing this to php-fpm via fastcgi_ variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# regular PHP fcgi block location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } # Jelix PathInfo PHP fcgi block location ~ .php($|/) { set $script $uri; set $path_info ""; if ($uri ~ "^(.+.php)(/.+)") { set $script $1; set $path_info $2; } fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; # PathInfo adjustment fastcgi_param SCRIPT_FILENAME $document_root$script; fastcgi_param PATH_INFO $path_info; # end include fastcgi_params; } |
Both should go under server block in nginx config.
Hi,
I have currently the same problem. Have you resolved it ?
BR,
Eric
Did you bother to read the post – it IS about this problem resolution.
Who ! I read too quickly your post. It works fine ! You save my day, thanks a lot.
location ~ \.php($|/) {
set $script $uri;
set $path_info $request_uri;
if ($path_info ~ “^(.+)\?(.+)$”) {
set $path_info $1;
set $real_query_string $2;
}
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param QUERY_STRING $real_query_string;
}