Building Rails and its friends on OSX

January 15, 2007

I recently switched to a mac and wanted to get our production environment running completely on my macbook so I could work remotely. To get there I followed the excellent instructions by Dan Benajaman at Hivelogic. But they are a little old now (versions mostly) and didn’t include some of the things I wanted. So this post is step by step (almost pastable) to get the following installed on OSX: MySQL, Subversion, ruby, ImageMagick, memcache, mongrel, and capistrano (as well as any dependencies).

You’re on your own for actually downloading the source tgz files, but they should be pretty easy to find. Also, there are a couple of comments (prefixed with #) that ask you to do something, so don’t just copy and paste blindly.

MYSQL

  1. Double-click the drive image to mount it
  2. Locate the MySQL installer (a file named something like mysql-standard-5.0.27-osx10.4-i686.pkg) and run it, authenticating as needed
  3. Double-click MySQLStartupItem.pkg, authenticate, and let it install
  4. Double-click MySQL.prefPane and install it, deciding whether to make it available to just the current user, or for all system users

Once the install is complete, start the MySQL server using the newly-installed control panel.

Note: MySQL installs with a default user of root which has no password. Please read this page about MySQL usernames and passwords and set a good one.

Subversion

  1. Just install it like any other mac app. Subversion 1.4.0

Everything Else

#
# edit /etc/csh.login and set the following:
#

setenv PATH "/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin"
setenv EVENT_NOKQUEUE 1

#
# edit /etc/profile and set the following:
#

export PATH="/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin"
export EVENT_NOKQUEUE=1

#
# relogin and make sure your path matches the above.
#

# 
# Force the use of tcsh so the couple of setenv/unsetenv belows work as is.
#
tcsh

# 
# where we're going to put all our sources
#
mkdir -p /usr/local/src

#
# copy all the source balls into this directory
#

cd /usr/local/src

tar zxvf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/usr/local
make
make install
cd ..

tar zxvf ruby-1.8.5-p2.tar.gz
cd ruby-1.8.5-p2
setenv CFLAGS -O
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local
make
make install
make install-doc
unsetenv CFLAGS
cd ..

tar zxvf rubygems-0.9.0.tgz
cd rubygems-0.9.0
ruby setup.rb
cd ..

sudo gem install rails --include-dependencies

tar jxvf freetype-2.1.10.tar.bz2
cd freetype-2.1.10
./configure --prefix=/usr/local
make
make install
cd ..

tar jxvf libpng-1.2.14.tar.bz2
cd libpng-1.2.14
./configure --prefix=/usr/local
make
make install
cd ..

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg
cd jpeg-6b/
ln -s `which glibtool` ./libtool
export MACOSX_DEPLOYMENT_TARGET=10.4
./configure --enable-shared --prefix=/usr/local
make
mkdir -p /usr/local/man/man1
make install
unsetenv MACOSX_DEPLOYMENT_TARGET
cd ..

tar zxvf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local
make
make install
cd ..

tar jxvf ImageMagick-6.3.1-0.tar.bz2
cd ImageMagick-6.3.1
./configure --prefix=/usr/local
make
make install
cd ..

tar zxvf libevent-1.2a.tar.gz
cd libevent-1.2a
ls
./configure --prefix=/usr/local
make
make install
cd ..

tar zxvf memcached-1.2.0.tar.gz
cd memcached-1.2.0

#
# edit memcached.h and add '#undef NO_TCPPUSH' to the top
#

./configure --with-libevent=/usr/local --prefix=/usr/local
make
make install

#
# do each one of these individually as some ask for versions
#

gem install rmagick -y
gem install tidy -y
gem install memcache-client -y
gem install mongrel -y
gem install capistrano -y
gem install mongrel_cluster -y