How to properly set fastcgi_param SCRIPT_FILENAME - nothing seems to work
April 21, 2021 08:59AM
Sorry for this noob question, but frustration is eating me.
I'm trying to set up my php app for 2 straight days, and no config seems to work to load it properly.

My config:

server {
server_name mydomain.com;
...
...

fastcgi_param HTTPS on;

location /app {
index index.php;
alias /var/www/app;

location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi.conf;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock;
}
}
}
But I also tried a number of other placements and combinations.

This will result (probably obviously) in a "No input file specified."

SCRIPT_FILENAME will never be taken unless I change it explicitly to /var/www/app/index.php (and in that case only that file loads, 404ing all other php files out).

What could be the issue? Where could I even debug this? (in terms of what file nginx is trying to feed php-fpm)
Re: How to properly set fastcgi_param SCRIPT_FILENAME - nothing seems to work
April 21, 2021 12:28PM
Ok, as expected, this was extremely stupid.
location /app { index index.php; root /var/www; }
When specifying location, the path should be set with root NOT containing the /location
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready