FAQ

Page Discussion Edit History

OnOpenBSD

Contents

[edit] Installing and configuring Nginx / Mongrel on OpenBSD with Rails support.

[edit] 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

[edit] Download and extract the nginx sources

Make sure to appropriately substitute the version numbers below:

$ wget http://sysoev.ru/nginx/nginx-X.X.XX.tar.gz
$ tar -xzvf nginx-X.X.XX.tar.gz

[edit] 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/nginx.pid \
              --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

[edit] Compile and install

$ make && sudo make install

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

[edit] 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.

[edit] Initializing Mongrel Cluster from your path/to/app/rails/

You can take the sample nginx.conf file from http://wiki.codemongers.com/NginxRubyonRailsMongrel and adjusting it to app

$ cd /var/www/rails_app/
$ sudo mongrel_rails cluster::configure 
$ sudo mongrel_rails cluster::start

[edit] Starting nginx

$ sudo /usr/local/sbin/nginx

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

$ lynx http://localhost

[edit] Restarting nginx

$ sudo kill -HUP $(head -1 /var/run/nginx.pid)

[edit] Shutting down nginx

$ sudo kill -QUIT $(cat /var/run/nginx.pid)

[edit] 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.