Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run CGI scripts on Nginx

I have problem setting up CGI scripts to be run on Nginx, so far I've found http://wiki.nginx.org/SimpleCGI this stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automatically

Do you have any idea? I'm running Centos 5

I've found some solutions here but I couldn't integrate code given there with this Perl script I'm completely zero at Perl, please help me Thanks

like image 898
Askhat Avatar asked Jul 26 '12 10:07

Askhat


People also ask

How do I run CGI on Nginx?

Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.

What is CGI Nginx?

FastCGI is a protocol based on the earlier CGI, or common gateway interface, protocol meant to improve performance by not running each request as a separate process. It is used to efficiently interface with a server that processes requests for dynamic content.


1 Answers

Nginx doesn't have native CGI support (it supports fastCGI instead). The typical solution for this is to run your Perl script as a fastCGI process and edit the nginx config file to re-direct requests to the fastCGI process. This is quite a complex solution if all you want to do is run a CGI script.

Do you have to use nginx for this solution? If all you want to do is execute some Perl CGI scripts, consider using Apache or Lighttpd as they come with CGI modules which will process your CGI scripts natively and don't require the script to be run as a separate process. To do this you need install the web server and edit the web server config file to load the CGI module. For Lighttpd, you will need to add a line in the config file to enable processing of CGI files. Then put the CGI files into the cgi-bin folder.

like image 69
David Farrell Avatar answered Sep 24 '22 19:09

David Farrell