First, install the Apple Xcode tools from your OS X installation disc.
Second, install DarwinPorts from here. It’s just a regular Mac package.
Now go to the terminal (Applications/Utilities/Terminal) and type the following commands:
sudo port -d selfupdate sudo port install lighttpd +ssl sudo port install rb-rubygems sudo port install rb-fcgi sudo port install mysql4 +server
If rubygems doesn’t install properly, try Jamie’s tip.
If the mysql install fails, try setting your GCC version back to 3.3 for the duration of the command:
sudo gcc_select 3.3 sudo port install mysql4 +server sudo gcc_select 4.0
The above trick may help you if other packages fail, too. You can try
mysql5; I’m just not sure if the ruby mysql bindings are current enough.
rmagick or postgres or others
Also maybe you want rmagick (more information):
sudo port install rb-rmagick
You could also use the gem (
sudo gem install rmagick) if you need a more up-to-date version. The gem version may have more complicated dependencies, though.
For postgres, do:
sudo port install postgresql81 +server
If you need other things, you can use
port list whatever to browse the available DarwinPorts packages.
whatever can contain wildcards (example:
port list rb* ).
fix the system path
/opt/local/bin to the system PATH in the file
/etc/profile, so that it looks as below. You might as well add
/opt/local/sbin and the
/usr/local/ folders while you’re at it. So in the end, the line should look like this:
The PATH environment variable tells the system where to look (and in what order) for executable files that are not run with an explicit path. It is better to put it in
/etc/profile, which is system-wide, as opposed to
~/.bashrc, which is specific to the current user.
Please note; if installing gems fails with some kind of
require error, try reinstalling the
rb-rubygems port. It seems to not complete correctly the first time around for many people.
Rails, rake, mysql:
sudo gem install rails sudo gem install rake # do this all on one line sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config
You may have to use
Make sure to choose a ruby version of the mysql gem, and not win32. If you are having compile errors with the 2.7 version, and are using the mysql.com distribution of MySQL instead of the MacPorts distribution, this article might help you.
sudo gem install capistrano
If you use postgres because of its awesomeness:
# do this all on one line sudo gem install postgres -- --with-pgsql-include-dir=/opt/local/include/postgresql81 --with-pgsql-lib-dir=/opt/local/lib/postgresql81
make lighttpd start automatically
Next, you can configure a webserver daemons. This step is optional, and not very useful if you don’t need to develop under a more deployment-like environment. Normally
script/server from the Rails directory will be your development web server.
The lighttpd configuration file lives at
/opt/local/etc/lighttpd.conf. If you put this file in
/Library/LaunchDaemons/, and load it into the launchd list via
sudo launchctl load -w /Library/LaunchDaemons/net.lighttpd.plist, it will boot automatically at start-up. You can then stop and start the lighttpd launchd daemon with
sudo launchctl start net.lighttpd, etc.
Note, loading the launchd item will fail if there isn’t a working configuration file at
make the db start automatically
Lastly, DarwinPorts will also put a file similar to
org.darwinports.postgresql81-server.plist in your
/Library/LaunchDaemons/ folder, depending on which RDBMS you have decided to install. You can use this to start the database server automatically, just like starting lighttpd as mentioned above. You need to do all the same steps:
sudo launchctl load -w /LibraryLaunchDaemons/org.darwinports.postgresql81-server.plist sudo launchctl start org.darwinports.postgresql81-server
Chances are, starting the server will silently fail. If you look at the
.plist file with a text editor, you will notice that it is calling some wrapper scripts that are probably in
/opt/local/etc/LaunchDaemons/ somewhere. If you execute these by hand, from the command line, you can see what the problem is. Usually it is expecting your actual database to be in some other location than where you put it, assuming you initialized the database at all. Resolve this either by modifying the wrapper script directly, or by adding the appropriate env variable to
I am assuming that you will be able to load your schema and configure your database users/roles yourself.
Note, don’t try to run two instances of
port in parallel, even if you have dual cores. They will fight.
Also, you will want an IDE/editor such as RadRails (yay!) or TextMate (hmm…). And you will need Firefox and probably want the following extensions: Web Developer, Tamper Data, Html Validator, FireBug, Tab Mix Plus, User Agent Switcher, ColorZilla, and MeasureIt.
Also, I recommend using a visual database modeler, even if you have to run it under Parallels. Your choices are mainly DBDesigner (mysql only, free), Toad Data Modeler (formerly CASE Studio, now free), Sybase PowerDesigner (expensive), and Rational Rose (expensive). You may expect your data model to stay simple, but chances are it won’t. The penalty for not understanding the complete implications of your data model is great; this is one place where the enterprise got it right. That said, do what you think is best.
And now you are done, and all set up to use Prototype to make the best lightbox ever, even better than the five hundred other ones which are also the best ever.
This is all based on me piecing together the things that worked for me on OS X 10.4.6 (Intel). Let me know if you have trouble.