Reputation: 479
I am setting up a website with nginx and need to let it run some perl programs, so I installed FastCGI and have it all set up. I added this to my site's configuration:
location ~ \.pl$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME /[...]/www$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
}
I then wrote a test.pl program:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "Body here ";
print $#ARGV;
And I do get the result as "Body here -1". So the perl program is correctly running. Now the only issue I have is that, for the life of me, I can't find how to read in POST data. If that's tricky, I also can't find out how to read in the GET URL parameters. Either would be sufficient for me.
Upvotes: 1
Views: 1981
Reputation: 479
This was simpler than it would have seemed. Below is the perl script I used.
#!/usr/bin/perl
use CGI;
print "Content-type:text/html\n\n";
my $q = CGI->new;
print "Your name is";
print $q->param("name");
And that's it. It's not specific to nginx at all.
Upvotes: 1