Installation and Configuration
So, I installed ubuntu, got all updates and installed them and enabled "universe" and "multiverse" in the apt sources list. Now I was ready to install ruby, rails, mysql and apache2.
sudo aptitude update
sudo aptitude install ruby rdoc ri rake apache2 mysql
Then I got RubyGems as source and installed using ruby. I was a bit sad that I couldn't get the "gem" tool using aptitude, but it looked like the ruby installer actually made a gem package and installed it as a gem, so from here on, it can be updated using itself, nice!
Then, I installed Rails:
sudo gem install rails --include-dependencies
And after installing rails, I installed my application:
- Installed (copied) my application into "/var/opt/rails/app"
- Recursively changed user and group on that dir to "www-data:www-data", as this is what apache runs as.
- Edited environment.rb to uncomment line about RAILS_ENV (makes it default to production if nothing explicit set)
- Created a new file "/etc/apache2/sites-available/app"
- Linked it to sites-enabled as "001-app"
- Linked "/etc/apache2/mods-available/rewrite.load" into "mods-enabled" (the .htaccess file in the rails application is using mod_rewrite to dispatch requests to "dispatch.cgi")
- Edited "/etc/hosts" to make the name "app" resolve to localhost IP (as I am using virtual host based apache setup)
Options ExecCGI FollowSymLinks
Allow from all
And simply restarted apache.
And then, stuff went wrong, and I found out I had to do these things:
- Put "socket: /var/run/mysqld/mysqld.sock" into "databases.yml", as ActiveRecord was using the socket file to connect to MySQL and the ubuntu installed MySQL has placed it under "/var/run/mysqld"
- Enabled x-bit on "dispatch.cgi" (because I had copied files from a windows partition)
- Change the shebang line in "dispatch.cgi", as it included a horrible "c:/..." line to where ruby is placed on my windows partition
Performance was horrible
As mentioned previously, the site is not going to take many hits at all. So I thought, with todays CPUs and forking speeds of Linux, this might be okay. Here are some numbers, from my 2GB, 2.26GHz Dell Latitude D810.
- 1 request, with no db-access took around 0,8-1,0 second (Auch!)
- 5 simultanous requests, to same page, ~5 seconds, with an average of ~5 seconds/request
- 15 simultanous requests, to same page, ~15 seconds, with an average of ~15 seconds/request
Maybe it would be better, if I was running the yarv vm?
Will be about the mongrel setup I did instead, which performs much better, but is a bit more complex to setup.
Still, even this simple setup, is far more complex than dropping a .war file in a web-container.