Node.js on OpenShift? You bet your Javascript

Developers have asked, and we listened.  Node.js has been a commonly requested feature for application deployments on OpenShift and our engineers have been tucked away banging out the code to make this happen.  Not only do we support node.js, its super secure with our usage of SELinux, c-groups, and pam_namespaces

Follow these steps to get Node.js applications deployed to the cloud in minutes:

Step 1: (Skip if you already have an OpenShift account)
Signing up for an OpenShift account is both free and easy.  In order to sign up, we only ask for an email address and password.  We don’t ask for your first name, your dogs name, how many cats you have or anything else.  Why makes things complicated by asking for data we don’t need.

Step 2: (Skip if you have clients tools already installed)
Now that you have an account on OpenShift, you can interact with our system via various methods.  The method I prefer is the command line tools.  In order to install and use the command line tools you will need to have both ruby and rubygem installed on your system.  Given the various ways of installing these dependencies on each operating system, I will not cover it in this post.  That being said, it is installed by default on most linux and mac operating systems.

Once you have ruby and rubygem installed, simply type the following, using sudo access if required:

$ sudo gem install rhc

Step 3: Create an application
In order to create an application on the OpenShift Paas, you can issue a single command that will both allocated a node for your use as well as install all the required dependencies for running node.js.  From a command prompt, issue the following command:

$ rhc app create –a yourApplicationName –t nodejs-0.6

This will also create a git repository and setup some git configuration files that will allow you to commit and push code changes to your node.js application server.

Verify that your application is up and running by pointing your browser to your freshly created application:

Step 4: Embed databases if you need
Now that we have our node.js application and running, you may want to add database support.  At the time of this writing, we support MongoDB, MySQL, postgreSQL and sqlite.  In order to use one of these databases, we need to embed the corresponding database cartridge.  This can be done with the following command:

$ rhc cartridge add –a yourApplicationName –c mongodb-2.0

The above will create a mongoDB database and make is accessible to your node.js platform.  If you wanted to use MySQL or another database, you would simply supply the cartridge name for the respective database.  To get a list of all available cartridges, you can issue the following command:

$ rhc cartridge list

Step 5: Code (That was point of this, right?)
Your application code has been clones from your git repository and is located in the directory where you issued the create application command.  At this point, change to the directory created and have a look around.  We provide a README file that will explain the layout of the application and how to include npm dependencies for your application.

Once you have made some changes, for your application code to served by your OpenShift node, you need to commit and push your change.

$ git commit –a –m “Added some source code”
$ git push

And that’s all there is to it.  You have a running node.js application complete with database support available on the cloud.

If you have any questions about using OpenShift, please contact us in one of the following ways:

Want to get started even faster?  Check out our quickstart guides posted on github at:


Comments are closed.