Installing and configuring NGINX / Mongrel on OpenBSD with Rails support

Install the PCRE library

It is advised you be familiar with installing packages on OpenBSD before proceeding. You can find OpenBSD’s package documentation here.

$ sudo pkg_add -v pcre

Download and extract the NGINX sources

Make sure to appropriately substitute the version numbers below:

$ wget
$ tar -xzvf nginx-X.X.XX.tar.gz

Configure the Makefile

$ cd nginx-X.X.XX/
$ ./configure --sbin-path=/usr/local/sbin/nginx \
              --conf-path=/etc/nginx/nginx.conf \
              --pid-path=/var/run/ \
              --with-http_ssl_module \
              --http-log-path=/var/log/nginx.log \
              --error-log-path=/var/log/nginx-error.log \
              --http-fastcgi-temp-path=/var/tmp/fastcgi_tmp \
              --http-proxy-temp-path=/var/tmp/proxy_tmp \
              --http-client-body-temp-path=/var/tmp/client_body_temp \
              --with-http_stub_status_module \
              --user=www --group=www

Compile and install

$ make && sudo make install

After NGINX has been installed, make sure to edit /etc/nginx/nginx.conf according to your needs.

Log files

By default, NGINX saves its logs as /var/log/nginx.log and /var/log/nginx-error.log. You may wish to configure NGINX so that it saves its logs on a per-host basis.

Initializing Mongrel Cluster from your path/to/app/rails/

Starting NGINX

$ sudo /usr/local/sbin/nginx

Testing, appoint your browser to rails app (localhost, default here)

$ lynx http://localhost

Restarting NGINX

$ sudo kill -HUP $(head -1 /var/run/

Shutting down NGINX

$ sudo kill -QUIT $(cat /var/run/

Final notes

The initial motivation for this article was a rapid introduction to install and setup NGINX on OpenBSD. Currently exist a port under /usr/ports/www/nginx. It can be the best way to install and handle new NGINX versions on this Operating System.

Whenever it article is nice and functional.