Ruby on Rails with OS X Tiger
I’ll admit there are already 12 million documents out there claiming to explain this, but for one reason or another I couldn’t get any of them to work as written. Ruby on Rails is undergoing rapid development, and OS X is not sitting still either. Here are the steps I used, which should continue to be relevant since I am installing from source instead of relying on the ruby package that comes with Tiger.
1. Install Xcode Tools
Insert your Mac OS X Install Disc 1. Find the Xcode Tools directory, in there you’ll find XcodeTools.mpkg. Double-click it.
2. Install MySQL.
http://dev.mysql.com/downloads/mysql/4.1.html
I installed Mac OS X 10.4 (x86) Standard 4.1.19, you can install whatever you want.
3. Install ruby
http://www.ruby-lang.org/en/downloads/
cd ruby-1.8.4
./configure
make -j5
sudo make install
4. Fix your PATH.
Add this line to ~/.profile
export PATH=/usr/local/bin:/usr/local/mysql/bin:${PATH}
Close and reopen your terminal window, and make sure it worked by running this:
echo $PATH
/usr/local/bin:/usr/local/mysql/bin:/bin:/sbin:/usr/bin:/usr/sbin
5. Make sure you have the right version of ruby
which ruby
/usr/local/bin/ruby
ruby -v
ruby 1.8.4 (2005-12-24) [i686-darwin8.6.1]
6. Install Ruby Gems
http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar xzf rubygems-0.8.11.tgz
cd rubygems-0.8.11
sudo ruby setup.rb
7. Install Rails
sudo gem install rails --include-dependencies
8. Install MySQL drivers
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql/
Pick this option:
3. mysql 2.7 (ruby)
9. Create a new Rails application
cd ~/Sites
rails myapplication
sudo chgrp -R www myapplication/tmp
sudo chmod -R g+w myapplication/tmp
10. Configure Apache:
sudo vi /private/etc/httpd/users/yourusername.conf
NameVirtualHost *:80
<VirtualHost *>
ServerName myapplication
DocumentRoot /Users/yourusername/Sites/myapplication/public
<Directory /Users/yourusername/Sites/myapplication/public>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
</Directory>
</VirtualHost>
sudo chmod 755 ~/
sudo apachectl restart
11. Edit /etc/hosts
sudo vi /etc/hosts
127.0.0.1 myapplication
Your done! With any luck, you should be able to visit http://myapplication/ with your browser and see the Welcome Aboard message from Rails. Error messages and debugging information will be in ~/Sites/myapplication/log/development.log.
Thanks to Saari Development for this post, which helped me put some of these pieces together.
Tell us what you think