Welcome! Log In Create A New Profile

Advanced

Help Processing a pl script pls

AMP Admin
June 26, 2009 03:42PM
I'm trying to get the "Easy PHP Version" for processing cgi-bin (http://wiki.nginx.org//NginxSimpleCGI) but I can't seem to get it right.

The following keeps returning 404. I know the file is there because when I remove the following it prompts me to download the file.

### CGI ###
location ~ ^/cgi-bin/.*\.(cgi|pl|py|rb) {
gzip off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index cgi-bin.php;
fastcgi_param SCRIPT_FILENAME /etc/nginx/cgi-bin.php;
fastcgi_param SCRIPT_NAME cgi-bin.php;
fastcgi_param X_SCRIPT_FILENAME /var/www/html/cgi-bin/awstats.pl;
fastcgi_param X_SCRIPT_NAME awstats.pl;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $remote_user;
}
### /CGI ###

I see this in the error log:
[error] 30432#0: *1 FastCGI sent in stderr: "PHP Notice: Undefined index: X_SCRIPT_FILENAME in /etc/nginx/cgi-bin.php on line 10

Here is cgi-bin.php:
<?php

$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);

$newenv = $_ENV;
$newenv["SCRIPT_FILENAME"] = $_ENV["X_SCRIPT_FILENAME"];
$newenv["SCRIPT_NAME"] = $_ENV["X_SCRIPT_NAME"];

if (is_executable($_ENV["X_SCRIPT_FILENAME"])) {
$process = proc_open($_ENV["X_SCRIPT_FILENAME"], $descriptorspec, $pipes, NULL, $newenv);
if (is_resource($process)) {
fclose($pipes[0]);
$head = fgets($pipes[1]);
while (strcmp($head, "\n")) {
header($head);
$head = fgets($pipes[1]);
}
fpassthru($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
}
else {
header("Status: 500 Internal Server Error");
echo("Internal Server Error");
}
}
else {
header("Status: 404 Page Not Found");
echo("Page Not Found");
}
?>
Subject Author Posted

Help Processing a pl script pls

AMP Admin June 26, 2009 03:42PM

Re: Help Processing a pl script pls

Jools Wills June 27, 2009 06:20AM

RE: Help Processing a pl script pls

AMP Admin June 27, 2009 01:58PM

RE: Help Processing a pl script pls

Jools Wills June 27, 2009 02:39PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 306
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready