Installing Rails and Apache on OS X (Intel)
Installing Rails/Apache on an Intel Mac can be slightly more daunting than a PPC install. Luckily, if all you are looking for is to play around with Rails, you can use Locomotive. If you want to use apache, though, these instructions should work. These instructions are a combination of my own experiences and these two articles from hivelogic.
First, install X Code tools. It is about an 822 meg package available from http://developer.apple.com. It also can be found on your OS X Install disk.
Make sure your path starts with /usr/local/bin and /usr/local/sbin. They need to be first in your $PATH. Edit your ~/.bash_login or ~/.bash_profile if you need to change it. When you are done, echo $PATH and make sure that your path is correct.
Install Readline:
curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz
tar xzvf readline-5.1.tar.gz
cd readline-5.1
./configure –prefix=/usr/local
make
sudo make install
* (If you get an error about needing to run ldconfig, ignore it and continue)
cd ..
Install Ruby:
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gz
tar xzvf ruby-1.8.4.tar.gz
cd ruby-1.8.4
./configure –prefix=/usr/local –enable-pthread –with-readline-dir=/usr/local
make
sudo make install
cd ..
Install Rubygems:
curl -O http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar xzvf rubygems-0.8.11.tgz
cd rubygems-0.8.11
sudo /usr/local/bin/ruby setup.rb
cd ..
Install Rails from gem:
sudo gem install rails –include-dependencies
Install Rubyzip (You may skip this step if you don’t want to use the rb-zip library in your app)
sudo gem install rubyzip
Install Fastcgi:
curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure –prefix=/usr/local
make
sudo make install
cd ..
Add Ruby-Fastcgi bindings:
curl -O http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
tar xzvf ruby-fcgi-0.8.6.tar.gz
cd ruby-fcgi-0.8.6
/usr/local/bin/ruby install.rb config –prefix=/usr/local
/usr/local/bin/ruby install.rb setup
sudo /usr/local/bin/ruby install.rb install
cd ..
Install Fcgi gem:
sudo gem install fcgi
Install Mod_Fastcgi for Apache:
curl -O http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar xzvf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
apxs -o mod_fastcgi.so -c *.c
sudo apxs -i -a -n fastcgi mod_fastcgi.so
cd ..
Install Pcre:
curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.6.tar.gz
tar xzvf pcre-6.6.tar.gz
cd pcre-6.6
./configure –prefix=/usr/local CFLAGS=-O1
make
sudo make install
cd ..
Install Lighttpd:
curl -O http://lighttpd.net/download/lighttpd-1.4.11.tar.gz
tar xzvf lighttpd-1.4.11.tar.gz
cd lighttpd-1.4.11
./configure –prefix=/usr/local –with-pcre=/usr/local
make
sudo make install
cd ..
Install Mysql bindings for Ruby:
sudo gem install mysql — –with-mysql-dir=/usr/local/mysql
mkdir ~/Sites/Rails, cd ~/Sites/Rails
rails TestRailsSite
Fix permissions so Apache can use the site:
sudo chgrp -R www TestRailsSite
cd TestRailsSite
chmod 0775 db
chmod 0777 log
chmod 0775 public
chmod 0666 log/*.log
Configuring Apache
sudo vi /etc/httpd/httpd.conf
Make sure the following lines are somewhere in the file:FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
Add this near the bottom of the file:
Alias /piper/ “/Users/YOURUSERNAME/Rails/piper_ror/public/”
Alias /piper “/Users/YOURUSERNAME/Rails/piper_ror/public/”<Directory /Users/YOURUSERNAME/Rails/piper_ror/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Configure project files.
vi public/.htaccess
Make sure these two lines are uncommented (edit as needed, of course):
RewriteEngine On
and
RewriteBase /TestRailsSite/
Change the line ‘RewriteRule ^(.*)$ dispatch.cgi [QSA,L]’ to:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
sudo gem install fcgi
I know, we did this once, but for some reason I had a problem with one of my machines and the first install didn’t complete successfully. Running it again at this point has fixed it anywhere I had that problem.
sudo apachectl graceful
navigate to http://localhost/TestRailsSite/ and you should see the welcome page!
May 3rd, 2006 11:25
[…] Option 3: Probably one of the hardest ways (Darwinports/Apache/Rails/Fastcgi): If you want to use a library like rb-zip, the only way I could get it to work was to install everything via darwinports. This isn’t the easiest process, but I have broken it down into exact steps. Follow them closely and you shouldn’t have any problems. I have put these steps into a separate article, which you can find here (PPC) or here (Intel). […]
August 29th, 2006 21:04
Regarding FastCGI: I could not compile fcgi because I continually received an error “-lSystem is not an object file” or “lc is not an object file” from libtool. According to http://crschmidt.net/blog/archives/119/os-x-104-compile-failures-due-to-libtool/ the problem stems from upgrading to Tiger but without upgrading the Developer Tools (Xcode 2). Although this own’t help any Intel users (assuming they all have Tiger installed to begin with, and not an upgraded OS), I found myself searching this page for a solution to that problem. Hope this helps!
November 15th, 2006 15:38
Please help. I’m spamming here because this is about the only intel specific install guid that I’ve found. I’m using the default ruby, but it works with lighttp and webrick, so I don’t think it’s the problem. I want to do some stuff that requires apache, but I keep getting:
Application error
Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html
If some kind person with a solution could email me at jdobbie@gmail.com it would be greatly appreciated
at the About your application’s environment
The development log has:
Operation not permitted - /Users/jdobbie/Sites/TestRailsSite/public/../config/../tmp/sessions//ruby_sess.9559d1397957123a
/usr/lib/ruby/1.8/cgi/session/pstore.rb:72:in `chmod’
/usr/lib/ruby/1.8/cgi/session/pstore.rb:72:in `initialize’
/usr/lib/ruby/1.8/cgi/session/pstore.rb:71:in `transaction’
/usr/lib/ruby/1.8/pstore.rb:129:in `catch’
/usr/lib/ruby/1.8/pstore.rb:129:in `transaction’
/usr/lib/ruby/1.8/cgi/session/pstore.rb:71:in `initialize’
/usr/lib/ruby/1.8/cgi/session.rb:273:in `new’
/usr/lib/ruby/1.8/cgi/session.rb:273:in `initialize’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/cgi_process.rb:112:in `new’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/cgi_process.rb:112:in `session’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/cgi_process.rb:108:in `stale_session_check!’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/cgi_process.rb:108:in `session’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:918:in `assign_shortcuts_without_flash’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/flash.rb:141:in `assign_shortcuts’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:402:in `process_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:150:in `process_request’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:54:in `process!’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:53:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each’
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:53:in `process!’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:23:in `process!’
/Users/jdobbie/Sites/TestRailsSite/public/dispatch.fcgi:24
February 8th, 2007 21:25
[…] * Fix permissions for rails directories so apache can use them Ref: http://bryan.e4industries.com/?p=6 sudo chgrp -R www-data railsapp chmod 0775 db chmod 0777 log chmod 0775 public chmod 0666 log/*.log […]