Serving CGI Scripts With Nginx On Ubuntu 12.04 - Page 3
4 Using FcgiwrapFcgiwrap is another CGI wrapper that should work also for complex CGI scripts and - like Simple CGI - can be used for shared hosting environments because it allows each vhost to use its own cgi-bin directory. Install the fcgiwrap package: apt-get install fcgiwrap After the installation, the fcgiwrap daemon should already be started; its socket is /var/run/fcgiwrap.socket. If it is not running, you can use the /etc/init.d/fcgiwrap script to start it. Now open your vhost configuration file... vi /etc/nginx/sites-enabled/www.example.com.vhost ... and add a location /cgi-bin {} section to the server {} container:
Reload nginx: /etc/init.d/nginx reload Next we create our cgi-bin directory - /var/www/www.example.com/cgi-bin because we defined root /var/www/www.example.com; in the location /cgi-bin {} container: mkdir /var/www/www.example.com/cgi-bin Now we place our CGI scripts in it and make them executable. For testing purposes I will create a small Hello World Perl script (instead of hello_world.cgi you can also use the extension .pl -> hello_world.pl): vi /var/www/www.example.com/cgi-bin/hello_world.cgi
chmod 755 /var/www/www.example.com/cgi-bin/hello_world.cgi Open a browser and test the script: http://www.example.com/cgi-bin/hello_world.cgi If all goes well, you should get the following output:
5 Links
About The Author![]() Falko Timme is the owner of
|





Recent comments
1 day 10 hours ago
1 day 12 hours ago
2 days 28 min ago
2 days 3 hours ago
2 days 7 hours ago
2 days 13 hours ago
2 days 23 hours ago
3 days 47 min ago
3 days 8 hours ago
3 days 10 hours ago