I still have some CGI scripts on this website. They still work, and they are good enough for my needs. When I switched this website to nginx (the wordpress setup was a little bit more complex than what I wrote in part 1, part 2 and part 3… the config will be one of my next blog posts) I was a little bit puzzled how to do that with nginx. It took me some minutes to get an idea how to do it and to find the right FreeBSD port for this.
- Install www/fcgiwrap
- Add the following to rc.conf:
fcgiwrap_enable="YES"
fcgiwrap_user="www"
- Run “service fcgiwrap start”
- Add the following to your nginx config:
location ^~ /cgi-bin/ {
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /path/to/location$fastcgi_script_name;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
}