I've got a simple script cpuinfo.sh that works and is executable.
I'm getting an error
*224 FastCGI sent in stderr: "Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?" while reading response header from upstream, client: 86.44.146.39, server: staging.example.com, request: "GET /cpuinfo.sh HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "staging.example.com"
the nginx settings are
location ~ (\.cgi|\.py|\.sh|\.pl|\.lua)$ {
gzip off;
autoindex on;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /home/balance/balance-infosystems-web/scripts/;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
I'm expecting fcgiwrap to execute
/home/balance/balance-infosystems-web/scripts/cpuinfo.sh
I hard coded the script path to debug but I'm still getting the same error.
location ~ (\.cgi|\.py|\.sh|\.pl|\.lua)$ {
gzip off;
autoindex on;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /home/balance/balance-infosystems-web/scripts/;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /home/balance/balance-infosystems-web/scripts/cpuinfo.sh;
}
What needs to be changed in the nginx server config to execute the script correctly?
I discovered that DOCUMENT_ROOT can not be reset. I normally have scripts directories away from publicly accessible paths. I knew that the scripts directory was the same level the web directory so I tried.
location ~ (\.cgi|\.py|\.sh|\.pl|\.lua)$ {
gzip off;
autoindex on;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root/../scripts/$fastcgi_script_name;
include fastcgi_params ;
}
which resolved the issue.