Posted On June 25th, 2014 by Sri vathsan. Posted Under Node JS
We would be using IBM Bluemix to host your node js application. IBM Bluemix is a cloud hosting platform that lets you to host your applications online. It accepts loads of different languages including even PHP. You could upload your PHP application too. But still, this is in beta as of now and it is free unless it is beta. Maybe they would have a free plan to go with, including loads of limitations. So now lets see on how you would host your Node application online using IBM Bluemix.
Hosting your First Node JS Application :
- name: NAME OF YOUR APPLICATION HERE
host: YOUR PREFERRED HOST
command: COMMAND YOU NEED TO RUN TO START THE APPLICATION
- name: xproweb
command: node server.js
5. Alright now that you have created your manifest file, open up your terminal and change directory to your Node application root folder. And type in the following command :
It would now prompt you for an Email ID and a password. Enter in the email and password that you used to sign up at Bluemix.
6. Now you need to make a small change to your code. Add the following snippet before everything in your server.js file. This is a must for every application.
var port = (process.env.VCAP_APP_PORT || 8192);
var host = (process.env.VCAP_APP_HOST || ‘localhost’);
7. Before you upload your application you MUST delete your node_modules folder. Cloud Foundry will look into your package.json file and it would install the dependencies by itself.
8. And its time to upload your application to Bluemix. Type in the following command in your terminal and hit enter to start upload.
Replace app_name with the name of your application as specified in your manifest.yml file. So now your application would be uploaded successfully. Just point your browser to the host provided in your manifest.yml file and you would see your application there !
There is also an alternative to Bluemix called as Heroku and you could check about it here.
That is it ! You now have a successful Node application running online ! Happy Node-ing