Thursday, August 25, 2011

Install Ruby on Rails 3 on Debian 6 (Squeeze) using RVM

First at all I decided to install Ruby & RoR using RVM because (yup, imma RoR n00b) seems to be a really common thing to switch between ruby versions,gems and anything while developing any kind of ror apps.
Also, because Debian version is (of course) outdated and besides that i ran into a lot of problems while i was trying to install it using the packages... Yeah, gotta love Debian <stable>. Errors like:
  • File not found: lib.
  • Execjs: Could not find a JavaScript runtime
  • And so on...
First some packages that you probably already have if you are a developer:
apt-get install curl git-core
Now because RVM downloads and compiles a LOT of the stuff we are installing you'll need:
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
(Again, if you are a developer you might already have some of em installed)

And this one if you plan to use Mysql on your project:
apt-get install libmysqlclient-dev
Here, make sure you don't have any Ruby packages installed and begin installing RVM (and from now on don't run anything as root):
bash < <(curl -sk
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
Now if you are a Gnome user make sure to check this option on your Terminal profile perferences (don't ask me why, just do it™ ):

To continue restart your Terminal, then:
// Checks if rvm is installed correctly (it MUST return 'rvm is a function')
$> type rvm | head -1

// Install Ruby and make sure it works
$> rvm install 1.9.2
$> rvm use 1.9.2
$> ruby -v

// Create a new gemset and install Rails
$> rvm gemset create rails305
$> gem install rails -v 3.0.5

// SQlite database extension
$> gem install sqlite3

// MySQl database extension
$> gem install mysql2
At this point if everything went OK you are good to go, still I recommend ya to run a simple app to make sure:
rails new HelloWorld
cd HelloWorld
rails server

Friday, August 12, 2011

Install MongoDB PHP driver on Debian 6 Squeeze

Install the server

apt-get install mongodb-server

Before install the PHP driver a couple of packages you'll need:

apt-get install php5-dev build-essential php-pear

Now time to compile/install the driver:

pecl install mongo

Once it finishes it will display the location of the new extension. Something like:


Finally add this to your php.ini (/etc/php5/cgi/php.ini):


Now restart your web server and that's should be it!

Saturday, August 6, 2011

Symfony2's "Upgrade your APC extension (3.0.17+)" problem

Somehow Symfony2 Standard (2.0.0) have a bug on the installer that produces an error while it checks APC version. (even if you don't have it installed it, APC is NOT a requirement for SF2)

Here is the patch to fix it:

Btw, This patch has already been commited to SF git, (not yet released).

Tuesday, August 2, 2011

Run Zend Framework (1.11) on lighttpd

Make sure this two mods are enabled on yer lighttpd.conf:



And add this to your host config:

$HTTP["host"] == "localhost" {
  url.rewrite-if-not-file = (
    ".*\?(.*)$" => "/index.php?$1",
    "" => "/index.php"

  # Not necessary, but most of Zend applications use it
  setenv.add-environment = (
    "APPLICATION_ENV" => "development"