Tuesday, September 20, 2011

Installing rabbit.js on Ubuntu 11.04 - Natty

So you want to run the following:

http://www.rabbitmq.com/blog/2010/11/12/rabbitmq-nodejs-rabbitjs/

This is a quick blog on installing node.js, RabbitMQ and then rabbit.js on Ubuntu 11.04. I may have forgotten a few steps, so please feel free to add comments.

1) Download Ubuntu 11.04 Natty Narwal iso (I am using 32bit)

http://www.ubuntu.com/download/ubuntu/download

2) I am running a MBP so I installed the iso on Fusion 3.1.3. I took the defaults and created a 20gig drive and standard 512MB RAM for memory.

3) Installing Node.js from source
  • Make sure that you do the following:
- sudo apt-get update
- sudo apt-get install ubuntu-dev-tools
- sudo apt-get install python2.7

- Python tools to interact with RabbitMQ (Perhaps for later not necessary for node)
- sudo apt-get install python-pip git-core
- sudo pip install pika==0.9.5
  • Here is the interesting part and I tried several different methods, but this seemed to work for me.
- Install node.js from the "Ubuntu Software Center" On the desktop goto: Applications->Ubuntu Software Center.
- Search for node.js and then select "Node.js event-based server-side javascript engine"

- Click on it and then install it. We are then going to "uninstall" once this has been completed. I don't know why...but it must bring the necessary dependencies. .

- Node.js will work if you install this way, BUT, Node Package Manager (npm) will not...and trust me you want the Package Manager

- Now following the instructions as written for the installation of Node.js:

- https://github.com/joyent/node/wiki/Installation

- Open a terminal and make sure you are at /home/[username] and follow the instructions to get node.js installed
  • Once you have node installed from the source...you should have a directory as follows:
- /home/[username]/local/node
  • node executable is now in your .profile and sourced, so you should be able to execute "node" in any terminal window.
  • Ok, now we need to get npm installed
- Execute in the terminal:: "curl http://npmjs.org/install.sh | sh" - If you are prompted to install curl, then go ahead and do that via apt-get and rerun the command. - You should be able to run npm and not get an error about not having some MRI viewing software. ;-)
  • Now let's get to the heart of this effort and install rabbit.js. In terminal go to /home/[username]/local/node/lib/node_modules
- Execute in the terminal: npm install amqp -g
- Execute in the terminal: npm install rabbit.js
- Execute in the terminal: npm install socket.io@0.6.17
- Execute in the terminal: npm ls (this command lists all of the installed node plugins)
  • If all went well you should then have a directory like this:
/home/vfabric/local/node/lib/node_modules
├── amqp@0.1.0
├─┬ npm@1.0.30
│ ├── abbrev@1.0.3
│ ├── graceful-fs@1.0.0
│ ├── ini@1.0.1
│ ├─┬ minimatch@0.0.4
│ │ └── lru-cache@1.0.4
│ ├── node-uuid@1.2.0
│ ├── nopt@1.0.8
│ ├── proto-list@1.0.0
│ ├── request@2.1.1
│ ├── rimraf@1.0.6
│ ├── semver@1.0.9
│ ├── slide@1.1.3
│ └── which@1.0.2
├── rabbit.js@0.1.1
└── socket.io@0.6.17

  • Now we need to get RabbitMQ installed. This is pretty straightforward:
- http://www.rabbitmq.com/releases/rabbitmq-server/v2.6.1/rabbitmq-server_2.6.1-1_all.deb
- In gnome, navigate to the Downloads folder and right mouse button the deb file
- Open the file with "Open With Ubuntu Software Center"
- This will state that an older version of RabbitMQ is installed. Go ahead and install this version

  • Nice management addins to install are the RabbitMQ Management plugins.
  • Download these addins from here:
- http://www.rabbitmq.com/plugins.html

rabbitmq_management

- mochiweb
- webmachine
- rabbitmq_mochiweb
- amqp_client
- rabbitmq_management_agent
- rabbitmq_management

rabbitmq_visualiser

- rabbitmq_management_visualiser

  • To install the plugins, you need to stop the server. In the terminal:
- Execute in the terminal: rabbitmqctl stop

  • Copy all of the .ez files in /home/[username]/Downloads to the RabbitMQ plugin directory
- Execute in the terminal: sudo mv ~/Downloads/*.ez /usr/lib/rabbitmq/lib/rabbitmq_server-2.6.1/plugins

  • Restart RabbitMQ with the following:
- Execute in the terminal: sudo rabbitmq-server
  • In firefox, navigate to http://localhost:55672 and login as guest / guest
- Hopefully, you should see the management console and the visualizer (pretty cool!)
  • Now, let's get node and rabbit chatting with each other. Navigate to /home/[username]/local/node/lib/node_modules/rabbit.js in the terminal.
- Execute in the terminal: node example/socketio.js
- You should see in the terminal...something like:

20 Sep 13:29:49 - Your node instance does not have root privileges. This means that the flash XML policy file will be served inline instead of on port 843. This will slow down initial connections slightly.
20 Sep 13:29:49 - socket.io ready - accepting connections

  • Finally...whew...if all of this is working...then you will be able to login into the node server at http://localhost:8080 and follow the instructions from there...if not...well it works on my vm. ;-)