Howto: Install Cloud9 IDE on CentOS 6.3 / Linux

There is an interesting (and free) alternative for those who are sick of (re-)installing Eclipse, Aptana, Zend Studio, PhpStorm, NetBeans or other IDEs on each new computer they use – or for those who don’t have 1 GB of RAM left to waste just to run a source code editor. I used to work with gedit mainly for performance reasons, but this option is (sadly) not viable on OS X (there is a working gedit version for OS X, but IMHO it is not really usable in practice).

Cloud9 is a Web based IDE that is almost entirely written in JavaScript and runs on Node.js on the server-side. You can either get it as ready-to-use cloud application (SaaS) at https://c9.io/ or you can install it for free on your own server / virtual machine, which is the option I have chosen.

In theory, the installation is easy. However, as I had to find out, there are a couple of things you need to know. For example, you should not use the lastest GitHub code or the latest Node.js release. The following steps are valid for CentOS 6.3, but experienced admins / developers should be able to apply them on other Linux distributions such as Ubuntu as well with just a few modifications (e.g. use apt-get instead of yum):

# Just in case NodeJS is already installed
yum erase nodejs npm
# Install required packages (hope I didn't miss something)
yum install git libxml2-devel libjpeg-devel python g++ make openssl-devel gcc-c++ gcc ruby ruby-devel rubygems tree
# FPM can be used to build custom package files for various Linux distributions
gem install fpm 
# Get Cloud9 from GitHub
git clone https://github.com/ajaxorg/cloud9.git
# Get and install latest Node.js 0.8.xx release, see http://nodejs.org/dist/
wget http://nodejs.org/dist/v0.8.25/node-v0.8.25.tar.gz
tar -xzf node-v0.8.25.tar.gz
cd node-v0.8.25
./configure --prefix=/usr/
make
mkdir /tmp/nodejs
make install DESTDIR=/tmp/nodejs/
# Create RPM file (for Red Hat / CentOS)
fpm -s dir -t rpm -n nodejs -v 0.8.25 -C /tmp/nodejs/ usr/bin usr/lib usr/share usr/include
rpm -ivh nodejs-0.8.25-1.x86_64.rpm
cd ../cloud9
# Latest stable version
git checkout v2.0.93
npm install -g sm
sm install
chown -R www-data:www-data .
cd ..
mv cloud9 /var/www
su www-data
# Run Web server and set /var/www as the base directory for the IDE
# The parameter -l 0.0.0.0 allows you to connect from hosts other than localhost (can be dangerous)
/var/www/cloud9/bin/cloud9.sh -w /var/www

Be aware that the installation instructions change from time to time: You should read the latest README.md for the Cloud9 release you want to install. These installation instructions are just a draft from my memory, so please write a comment, if I missed something or you know how to optimise it.

Shortcut when using my pre-built CentOS 6.3 x86_64 RPMs (Cloud9 2.0.93 and node.js 0.8.25):

wget /downloads/rpm/centos-6.3/nodejs-0.8.25-1.x86_64.rpm
wget /downloads/rpm/centos-6.3/cloud9-2.0.93-1.x86_64.rpm
rpm -ivh nodejs-0.8.25-1.x86_64.rpm cloud9-2.0.93-1.x86_64.rpm
npm install -g sm
cd /var/www/cloud9/bin
su www-data
cloud9.sh -w /var/www

Security notice: Since Cloud9 does not seem to provide SSL (https) by itself currently, you should either just use it on localhost, use port-forwarding with ssh or setup a SSL & authentication proxy in front of Cloud9/Node.js. Cloud9 by default runs on port 3131.