Ruby 1.9 and Nginx on FreeBSD
Noticed some, um, interesting, gotchas when setting up ruby 1.9 and the nginx web server on FreeBSD.
The issue with the ruby install is subtle, and doesn’t really show up until long after you have installed it. The issue is it points the gem repository to the wrong place. It points the gem repository to /usr/local/lib/ruby/gems/1.8 which is where the 1.8 gems should reside, not the 1.9 gems.
The ruby 1.9 gems should reside at /usr/local/lib/ruby/gems/1.9. And the default install doesn’t set that up. A sure way to make that happen is to put:
RUBY_DEFAULT_VER=1.9
in the /etc/make.conf file. It’s possible that adding the “-E RUBY_DEFAULT_VER=1.9” flag on the make command will do the same thing, but I found the make.conf change worked, so I stopped at that point.
Make that change before you install ruby19 from the ports:
cd /usr/ports/lang/ruby19
make install clean
After that, the gems will install in the right location and everything will be work the way it’s supposed.
Nginx
The regular ports install for Nginx, on the other hand, is defective from the get-go. While the ruby issue is a subtle one that may not even pose a problem in some circumstances, the ningx issue will prevent the server from responding to any control scripts.
The issue here is the default configuration script points the .pid file to the wrong location. In the default nginx.conf file installed by the ports system is the line:
pid logs/nginx.pid;
This means the control scripts will not be able to find the nginx.pid file in order to send it signals. Instead the line needs to read:
pid /var/run/nginx.pid;
This will locate the nginx.pid file where the control scripts can find it, and everything will work.