Linux 需要有关Nginx CGI配置的帮助吗

Linux 需要有关Nginx CGI配置的帮助吗,linux,nginx,cgi,fastcgi,Linux,Nginx,Cgi,Fastcgi,我需要设置nginx配置,以便URL“”应该触发shell脚本“hw.sh”出现在路径“/usr/lib/cgi-bin/”下 现在,根据第页中提到的说明,我们需要在“.vhost”文件下设置配置。但是我在路径“/etc/nginx/sites available/default”下已经有一个默认文件,而不是.vhost文件 当我使用相同的配置时,我得到HTTP/1.1403禁止错误。我已确保脚本也具有所需的可执行权限。以下是nginx日志中收到的错误 FastCGI sent in stder

我需要设置nginx配置,以便URL“”应该触发shell脚本“hw.sh”出现在路径“/usr/lib/cgi-bin/”下

现在,根据第页中提到的说明,我们需要在“.vhost”文件下设置配置。但是我在路径“/etc/nginx/sites available/default”下已经有一个默认文件,而不是.vhost文件

当我使用相同的配置时,我得到HTTP/1.1403禁止错误。我已确保脚本也具有所需的可执行权限。以下是nginx日志中收到的错误

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: host_ip, server: localhost, 
request: "HEAD /cgi-bin/hw.sh/some/path/to/data/ HTTP/1.1", 
upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "host_ip"
我需要帮助编写正确的配置,以便上面的URL在上面提到的路径下执行hw.sh脚本并返回正确的输出。有人能帮帮我吗

下面是我在默认文件下使用的配置

server {
        listen 80 default_server;
[...]    
location /cgi-bin/ {
         # Disable gzip (it makes scripts feel slower since they have to complete
         # before getting gzipped)
         gzip off;
         # Set the root to /usr/lib (inside this location this means that we are
         # giving access to the files under /usr/lib/cgi-bin)
         root  /usr/lib;
         # Fastcgi socket
         fastcgi_pass  unix:/var/run/fcgiwrap.socket;
         # Fastcgi parameters, include the standard ones
         include /etc/nginx/fastcgi_params;
         # Adjust non standard parameters (SCRIPT_FILENAME)
         fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       }
[...]
}
配置中的行“fastcgi\u参数脚本\u文件名$document\u根$fastcgi\u脚本\u名称;”导致了问题。 当我将其更改为“fastcgi_param SCRIPT_FILENAME$request_FILENAME”时,一切正常。

配置中的“fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_SCRIPT_name;”行导致问题。
当我将其更改为“fastcgi_param SCRIPT_FILENAME$request_FILENAME;”时,一切正常。

CGI与fastcgi完全不同,但是.CGI与fastcgi完全不同,但是。+1,这是一个比串联两个变量(或常量和变量)更优雅的解决方案正如SO.+1上的其他类似Qs中所建议的,这是一个比SO上的其他类似Qs中所建议的将两个变量(或常数和变量)串联起来更优雅的解决方案。