Setting up and Testing Rails apps on Mac OS X

I've been rapidly prototyping and developing a lot of Ruby on Rails applications. I don't want to run lots of WebBrick servers, or configure lighty. I'd rather just use apache for local development, which is much quicker and doesn't involve ports, and explicitly running stand-alone servers.

The instructions below are the quick, and bare-bones steps needed to get a rails app up for development on a Mac OS X machine.

Create your rails application


$ rails ~/Projects/myapp

Edit your apache config file


You need to setup your apache to know how to handle the /myapp URL request. Put the following at the bottom of your httpd.conf file.

/etc/httpd/httpd.conf


FastCgiServer /Users/username/Projects/myapp/public/dispatch.fcgi
-idle-timeout 120 -initial-env RAILS_ENV=development -processes 1
Alias /myapp/ "/Users/username/Projects/myapp/public/"
Alias /myapp "/Users/username/Projects/myapp/public/"


  Options ExecCGI FollowSymLinks
  AllowOverride all
  Order allow, deny
  Allow from all

Restart Apache


After you've edited the file, you need to restart apache:
$ sudo apachectl graceful

Set the rails base address


Now you need to let rails know what the base address is for the URL's:
~/Projects/myapp/public/.htaccess

RewriteBase /myapp

Test that it works


Navigate your browser to http://localhost/myapp, and you should see the happy Welcome aboard

About this article

written on
posted in ProgrammingAppleWebRails Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.