Ruby on Rails is the framework, and Ruby is the language. Four hours into my first real attempt at a working site, and I am excited. Currently my forte and preference is PHP, however very soon , I believe, that will change.
Here on forthecode.com you will find my journal recounting anything of value I may have picked up on the way. In fact the first thing I intend to share was a question I had but couldn't find any quick answer to. With Apache 2 on Debian (or just about any other Apache 2 setup) - how do I set up a Ruby on Rails Site?
Well my personal server runs on Debian Sarge with Apache 2 and is nicely managed by ISPConfig. I recently installed Rails and all the necessary packages. After creating this initial basic site I decided it was time to move the site from my CVS repository to the public web directory. However I was a bit unsure on where everything should go (did the entire project go into the public_html folder, or just the public folder?).
- Everything in your rails project goes in the base 'web' directory excluding stuff in the public folder - it goes in your public_html folder.
Pretty obvious right? Well, I wasn't quite for certain at first.
So now you have everything in its place, so you expect it to work right? Well in my case the webserver Apache threw an exception (precisely a 500 internal server error). Checking my server logs displayed the following message:
[Sun Mar 05 22:24:24 2006] [alert] [client 68.62.233.157] /home/www/web1/web/.htaccess: Options not allowed here
Well this threw me for a loop (sorta). I checked my .htaccess file in the web directory and the options that were being requested were:
Options +FollowSymLinks +ExecCGI
Well I attempted to change my /etc/apache2/apache.conf file to Allow Override, but that didn't quite work for me. So instead I opted to include those options for all of my web directories (hey, I plan on future development!). So I changed the Directory statements at the bottom of the conf file to something similar to the below setup:
<Directory /home/www/*/web>
Options +Includes -Indexes +FollowSymLinks +ExecCGI
...more stuff
</Directory>
The test gave that great feeling of success when you see a different error (hey it means one down - perhaps just another to go). This error was a little different and didnt make much sense at first.
(2)No such file or directory: exec of '/home/www/web1/web/dispatch.cgi' failed
Premature end of script headers: dispatch.cgi
This perplexed me for a good 20 minutes because the file was there! I figured it out after I decided to open the dispatch.cgi file with nano. My problem was simply that the dispatch.cgi was unable to acces some other file. Since I develop on a windows machine it was still referencing a path on my C: drive (quite incompatible with my Debian Linux server)! The first line right at the top needs to be changed to the directory of your ruby directory (keep the shebang!). If you are on a production machine like mine it should look similar to the line below:
#!/usr/bin/ruby
Well that wasn't hard. After the next test I was very pleased to see something quite different - a standard Ruby on Rails error! This error was perhaps the easiest to debug - my database.yml file had to be updated. And while I was editing my database file, I made certain to set my socket: (/path/to/mysql.sock). A quick slocate for mysql.sock presented this path for me:
/var/lib/mysql/mysql.sock
Well that was it! I had my rails app working (your looking at it or at least its descendant at this moment! Happy coding =)

Charles said:
Oh, the memories... soon I'll have to upgrade rails, MySQL and server - and I'll be glad I kept this (and will most likely add to it!)
2006-04-15 13:31:23 UTCCharles said:
Just as an update one error that I left out (i ran across it again after setting up another domain on my server) - if you see the following in your /home/..pathtosite../log/error.log :
[error] [client 68.62.171.123] (13)Permission denied: exec of '/home/www/web9/web/dispatch.cgi' failed
It means you need to 'chmod 655 dispatch.cgi' which is found in your public web directory (in my case 'web')
2006-05-20 19:05:49 UTCCharles said:
A note on mysql.sock on Ubuntu - MySQL 5 places the .sock file in /var/lib/run/mysql/mysqld.sock
2006-12-17 09:44:10 UTCCharles said:
I had to create a symbolic link to it:
sudo ln -s /var/lib/run/mysql/mysqld.sock /var/lib/mysql/mysql.sock
2006-12-17 10:01:22 UTCCharles said:
Will soon add a new post covering the conversion to a new server running Ubuntu (not much different from debian) and only running lighttpd instead of apache and lighttpd
2006-12-17 20:47:50 UTCCharles said:
The first of the two articles covering setting up Rails on Ubuntu can be found here: Ubuntu with Ruby on Rails!
2006-12-24 08:17:59 UTCCharles said:
And the second one can be found here: Ubuntu on Rails part 2!
2006-12-24 12:23:57 UTC