How To Install MacPorts, Apache2, Rails, MySql, Mongrel, and Subversion on an Intel Mac

27 Feb 2007 in Apple, Macintosh, Ruby on Rails, Subversion by Garrick

Now that I’m just about ready to deploy my first rails app, I thought I’d get the deployment environment set up rock solid on both the production and the development machines (one Mac Mini and one MacBookPro).

Like many other tutorials on this same subject, your mileage may vary. In fact I’m writing this now, because mine did. After stalling out in many of the tutorials all different places, this is what worked for me.

  1. Download and install MacPorts (used to be DarwinPorts)
  2. Open up a terminal and type:
    sudo port selfupdate
    making sure everything is the way it should be.
    If you’re like me, you get port: command not found in return.
  3. I fixed this by opening up .bash_profile in a text editor (Textmate: mate ~/.bash_profile) and adding the line
    export PATH=/opt/local/bin:$PATH
  4. Next download and install MySQL5
    I grabbed the binary from the bottom of the MySQL 5 download page. It comes with a System Preference Pane and checkbox for auto-startup. I’m using CocoaSQL for admin.
  5. Change the MySQL5 root password

    /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
    /opt/local/lib/mysql5/bin/mysqladmin -u root -h [HOSTNAME] password 'new-password'
  6. Next load up the Apache2 package
    sudo port install apache2
    (this takes a while)
  7. sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist to launch Apache2 on startup. I’ve disabled Apple’s default Web Sharing in the System Preferences.
  8. Create an initial http.conf file
    cd /opt/local/apache2/conf
    sudo cp httpd.conf.sample httpd.conf
  9. Start up Apache2
    sudo /opt/local/apache2/bin/apachectl -k start
  10. Load up http://localhost. It should say “It works!”

  11. sudo port install fcgi
    sudo port install lighttpd +ssl
    sudo port install mod_fastcgi
  12. Next load up Subversion package with the mod_dav_svn for Apache2
    sudo port install subversion +mod_dav_svn +tools
  13. Next load up Ruby, RubyGems, Termios, RB-MySQL5 Bridge, and ImageMagick Packages
    sudo port install ruby
    sudo port install rb-rubygems
    sudo port install rb-termios
    sudo port install rb-fcgi
    sudo port install rb-mysql (I had some errors on this one.)
    sudo port install imagemagick
  14. Install a bunch of useful gems, like rails and capistrano.

    sudo gem install --include-dependencies rake
    sudo gem install --include-dependencies rails
    sudo gem install --include-dependencies termios
    sudo gem install --include-dependencies capistrano


    sudo gem install daemons gem_plugin mongrel mongrel_cluster --include-dependencies
    sudo gem install --include-dependencies mongrel
    sudo gem install --include-dependencies mongrel_cluster


    sudo gem install mysql -- \
    --with-mysql-dir=/usr/local/mysql \
    --with-mysql-include=/usr/local/mysql/include/ \
    --with-mysql-lib=/usr/local/mysql/lib/ \
    --with-mysql-config=/usr/local/mysql/bin/mysql_config

    (thanks to d. robert adams for the last bit)
  15. Create a rails app
    rails testapp
  16. Connect the rails app to mongrel

    cd /RAILS/ROOT/OF/TESTAPP
    mongrel_rails cluster::configure -e development -p 8000 -a 127.0.0.1 -N3 -c /RAILS/ROOT/OF/TESTAPP

Comment | Trackback URL Short Link: http://grv.me/585

Comments (11)

[...] At this point I realized it was system configuration issue and not application specific. Luckily Garrick Van Buren had the same kind of issue with MacPorts and his bash client. His tip let me to search where the bin directory path was set with the env [...]

Vivisecting Media » Blog Archive » Installing Erlang on OS X added these pithy words on Feb 16 08 at 9:03 pm

[...] basis for my steps started out with this great post from Garrick Van Buren. I basically followed his steps exactly, but encountered a problem when I [...]

Conscious Bits… - » Ruby on Rails Development Setup on an OS X 10.5 MacBook Pro added these pithy words on Jun 11 08 at 6:11 pm

This is nice set of instructions, but if you’re using Apache2 in conjunction with mongrel why did you install the lighttpd web server package? I thought it was more typical to choose one or the other when you’re installing Rails.

Jason Gilman added these pithy words on May 27 07 at 10:52 pm

Hi , I am having trouble installing apache2

When I attempt to intstall I get this error:

Error: Unable to execute port: wrong # args: should be “proc name args body”

I’ve typed in the unix line multiple times as well, when I put a space between apache and 2 “apache_2″ I get:

—> Cleaning apache
Error: Port 2 not found

Could you please help explain my problem?

Nathan Nash added these pithy words on Jun 15 07 at 5:41 pm

I had the same problem. You’ll need to install the XCode package from http://developer.apple.com/tools/download/

Michael Just Hansen added these pithy words on Jun 17 07 at 3:30 pm

I downloaded and installed xcode yet I still recieve the same error. any clue as to why? also is there a way to check to see if you have installed mysql5 properly?

Nathan Nash added these pithy words on Jul 04 07 at 6:24 pm

Did you run the “sudo port selfupdate” command? If not, try that.

Michael added these pithy words on Jul 24 07 at 4:32 pm

considering you’re recommending the stock mysql 5 package, wouldn’t mysqladmin be in /usr/local/mysql/bin/mysqladmin instead of /opt? or are you suggesting we should use the mysql 5 that comes with MacPorts?

Robb Irrgang added these pithy words on Aug 21 07 at 10:59 am

I am definitely going to be following this when I get my new iMac on wednesday evening.

arikjones added these pithy words on Nov 06 07 at 9:29 am

Very helpful. Here is a command summary of my apache2 subversion mod_dav_svn install (starting configuration). Basically I did:

$ sudo port selfupdate
$ port -v
MacPorts 1.600

$ sudo port install apache2
$ sudo port uninstall subversion # was already installed without mod_dav_svn
$ sudo port install subversion +mod_dav_svn +tools

$ cd /opt/local/apache2/conf
$ sudo cp httpd.conf.sample httpd.conf
$ sudo vi httpd.conf # added Include
$ cat httpd.conf | grep svn # no match
$ cat httpd.conf | grep subversion
Include conf/extra/httpd-subversion.conf
$ cat /opt/local/apache2/conf/extra/httpd-subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so

DAV svn
SVNPath /Library/Subversion

$ curl http://localhost/svn/
svn – Revision 16: /

svn – Revision 16: /

pcj/

Powered by Subversion version 1.5.0 (r31699).

Paul Johnston added these pithy words on Jul 22 08 at 3:37 pm

Oops, the angle brackets were not escaped in my post. View source to get a better reflection of the command outputs above

Paul Johnston added these pithy words on Jul 22 08 at 3:39 pm

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Related Entries




Creative Commons License
About Sitemap XHTML Sitemap XML
Wordpress theme is a heavily hacked version of "Modicus Remix" by Art Culture. Original by Upstart Blogger