I enjoy using OpenSolaris when I can, and I’ve been using it for a couple small Ruby on Rails deployments. I’ve received a few questions recently about deploying Ruby on Rails app on OpenSolaris, so to kill a few ‘birds’ with one stone. I’m throwing this post together so that I can just point them here and let them run with it.
Sun has an easy to install meta-package called
amp that includes Apache 2.2, Apache 2.2 DTrace probes, MySQL Server 5.1 & PHP. If you’ve never used Solaris/OpenSolaris before the
pfexec command will seem foreign to you. Don’t let it worry you its part of the Solaris RBAC (Role Based Access Control) by default the non-root user you created during the install has the
root user role and can execute commands as root if you use
I’m assuming you’re starting from scratch on an OpenSolaris 2009.06 server with nothing extra installed. I also assume you’ve had some experience with a Unix/Linux variant.
We want to install some of the GNU stack including
gcc and git + subversion. We’re going to install git from source to be sure we’re on the latest release.
gmake, gcc, subversion and curl
curl is required to build
git don’t skip installing
SUNWcurl from above.
Note: There seems to be an issue with building versions of git newer than 22.214.171.124 on OpenSolaris 2009.06. I’ll figure out why but in the meantime I’ve provided instructions for installing git 126.96.36.199. Please verify that
/usr/local/bin is in your
Apache Stack (AMP)
Like I noted above, OpenSolaris has a meta-package we can install that will take care of most of this. It will install the following packages for us:
- MySQL Server 5.1
- Apache 2.2.30
- PHP 5.2.9
Enable Apache & MySQL Services
By default the Apache and MySQL services are not enabled. To turn them on run the following commands:
Ruby & Ruby on Rails
First we are going to use the Sun provided Ruby 1.8.7 package that also installs rubygems. Then we will update rubygems, install the gemcutter gem, add http://gems.github.com as a gem source (for legacy purposes), install the rails gems and finally modify our path to include the gem binaries.
(Note: Modifying .profile requires you to re-login to the machine, as it’s only read during that point. If you like you can add that same line to your .bashrc file)
Install Database Gems
We need to install fastthread and passenger, then configure apache to use it. We’re going to install passenger from source as it fixes a bug with the use of PTHREAD_STACK_MIN (See here) This is fixed in passenger 2.2.6 and I will update this when that is released.
We’re going to keep the passenger configuration in it’s own file to keep the httpd.conf clean.
Create the file:
Paste the lines from the passenger-install-apache2-module command in that file. My file contains the following:
Lets create a little rails app to verify that rails and passenger
Lets add a vhost config for apache.
Here is the contents of my file:
127.0.0.1 test-site.com to
Test the site in apache and you see the following: