Ruby on Rails
RailsOnOpenBSD

Instructions:

If you’ve already got Rails up and running but are just running into issues with Apache, see the bottom of this document.

You can build ruby and ruby-gems from source and there are some old instructions below. However if you have a fast internet connection, OpenBSD provides binaries to these same packages. As of OpenBSD 4.2 you get ruby-1.8.5p7 and ruby-gems-0.9.4p0. If you want ruby-1.8.6-111 I posted an article here. Ok, here is the binary way:


# Please choose a mirror near you
export PKG_PATH=ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386
pkg_add ruby ruby-gems ruby-iconv mysql-server mysql-client
gem install rails --include-dependencies
gem install mysql

Now here are the original build from source instructions.

Next build and install the ports, note that you’ll need to add the package for iconv support after you build the package:


# cd /usr/ports/lang/ruby && make install
# cd /usr/ports/devel/ruby-gems && make install
# pkg_add /usr/ports/packages/i386/all/ruby-iconv-1.8.4p0.tgz

If all goes well you’ll have a working ruby (with iconv support) and gems binary ready to install Rails

Now to install rails:


# gem install rails

If you want \RedCloth:


# gem install \RedCloth

If you want FastCGI support (for production environments)

FastCGI using ports:


# cd /usr/ports/www/fcgi && make install
# gem install fcgi

FastCGI using packages:


# setenv PKG_PATH ftp://ftp.openbsd.org/pub/OpenBSD/3.7/packages/i386/
# pkg_add ${PKG_PATH}fcgi-2.4.0.tgz
# /usr/local/bin/gem install fcgi -r -- --with-fcgi-lib=/usr/local/lib \
--with-fcgi-include=/usr/local/include

Next you’ll need to…

Deal with Rails inside of the Chrooted Apache:

See HowtoSetupChrootedApacheWithRailsOnOpenBSD

Alternatively you can disable the httpd chroot using the -u option. See the httpd man page for more information. You’ll want to modify or add httpd_flags="-u" to /etc/rc.conf.local then start or restart Apache.

Using Rails with Lighttpd and \FastCGI

Assuming \FastCGI was installed as decribed above

Install Lighttpd* from ports


# cd /usr/ports/www/lighttpd && make install

Edit /etc/lighttpd.conf as described here

Start Lighttpd (add this to rc.local for automation)
/usr/local/sbin/lighttpd -f /etc/lighttpd.conf