Fighting against ruby, rails, gems, php and apache on mac os x (and maybe something else I forget)

Last time I did some tests with rubyonrails, I made it over a pc box. This time I decided to give another try on installing everything on my laptop, as it's easier to start and stop ruby applications from my own console and not by running a VNC viewer and then accessing the windows command line, etc.

I must recognize that my previous attempts on installing rubyonrails, apache2 or php5 on this computer left the web thingie completely unusable here. Even the apache server which came installed with tiger by default was not working anymore. Not to mention my ridiculous achievement: install all of rubyonrails, see it worked and do some simple scaffoldings and then destroy it again by trying to not to use webrick and use apache2 instead (which is what led to not to have even normal apache running).

But maybe today was my day and for some strange stars and planets alignment I tried again and finally got everything working. So, just in case it's useful for someone:

I started here, on How To Install on OS X Tiger. Then on point 3 I switched and followed the instructions at Darwin Ports, untill I got rails installed.

Then I came back to How To Install on OS X Tiger, and then to mysql website to get latest installable version of mysql for mac Os. They have a very nice installation program which will do everything for you.

Once that was done, I created the ruby mysql binding with sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql, so ruby can communicate with the mysql database. (Some tutorials say you need to put the whole /usr/local/mysql 5.5.0... directory... but that's not exactly true as the mysql installation procedure creates a symbolic link called /usr/local/mysql)

After that I needed a way of launching the applications and the ports and so on. On Rails On Osx I found there was an application framework called Locomotive which could help me in doing that. In fact, I think it has everything that I neded and if I had find it before I shouldn't have had to do the points above, but hey that's a way of learning.

Installed that one, launched it (Applications -> Locomotive folder -> Locomotive) and then created a simple application just for testing (click the + sign, obvious!) and started it. I went to the browser and typed in http://localhost:3000/ and yeeeeeha! it was working: Congratulations, you've put Ruby on Rails!

But I hadn't had enough... now was time for ... apache2 and php5! Luckily I found a very nice article that explained everything very clearly, at phpmac: Building and Installing Apache 2 and PHP 5.0.5 on Mac OS X 10.4 Tiger. The only thing that was a bit tricky was the download locations for the source code files, both for apache and php. as sometimes the mirrors weren't working at all. I presume one can simply download the files manually and uncompress them where needed, without having to use curl for getting them.

In any case it worked like a charm. After several long minutes compiling and making configurations and installs (still don't get how people loves to rebuild and recompile the kernel just for the sake of doing it), seems like I have managed to get both running!

Needless to say, I have no words for this. I'm deeply impressed :D

UPDATE 7 december 2005: this tutorial seems to be interesting too: how to set apache2 to be the default mac os X httpd server.