Serving CGI Scripts With Nginx On OpenSUSE 12.2 - Page 2
3 Using FcgiwrapFcgiwrap is a CGI wrapper that can be used for shared hosting environments because it allows each vhost to use its own cgi-bin directory. As there's no fcgiwrap package for OpenSUSE, we must build it ourselves. First we install some prerequisites: zypper remove patterns-openSUSE-minimal_base zypper install git patch automake glibc-devel gcc flex compat-readline4 db-devel wget gcc-c++ make vim libtool FastCGI-devel Create the following symlinks: ln -s /usr/include/fastcgi/fastcgi.h /usr/local/include/ Now we can build fcgiwrap as follows: cd /usr/local/src/ This installs fcgiwrap to /usr/local/sbin/fcgiwrap. Next we install the spawn-fcgi package which allows us to run fcgiwrap as a daemon: zypper install spawn-fcgi We can now start fcgiwrap as follows: spawn-fcgi -u nginx -g nginx -s /var/run/fcgiwrap.socket -S -M 0700 -F 1 -P /var/run/spawn-fcgi.pid -- /usr/local/sbin/fcgiwrap You should now find the fcgiwrap socket in/var/run/fcgiwrap.socket, owned by the user and group nginx. If you don't want to start fcgiwrap manually each time you boot your system, open /etc/init.d/boot.local... vi /etc/init.d/boot.local ... and add the spawn-fcgi command at the end of the file - this will automatically start fcgiwrap at the end of the boot process:
Now open your vhost configuration file... vi /etc/nginx/nginx.conf ... and add a location /cgi-bin {} section to the server {} container:
Reload nginx: systemctl reload nginx.service Next we create our cgi-bin directory - /srv/www/www.example.com/cgi-bin because we defined root /srv/www/www.example.com; in the location /cgi-bin {} container: mkdir /srv/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 /srv/www/www.example.com/cgi-bin/hello_world.cgi
chmod 755 /srv/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:
4 Links
About The Author![]() Falko Timme is the owner of
|





Recent comments
1 day 2 hours ago
1 day 8 hours ago
1 day 12 hours ago
1 day 14 hours ago
2 days 4 hours ago
2 days 4 hours ago
2 days 9 hours ago
2 days 16 hours ago
2 days 16 hours ago
2 days 18 hours ago