Installing and configuring Node.js on Ubuntu 12.04 for localhost and external multi-site Drupal installations

First, get the pre-requsite packages:

sudo apt-get install build-essential g++ libssl-dev curl git

Then, install the Python Software Properties package:

sudo apt-get install python-software-properties

Add the repository for node.js:

sudo apt-add-repository ppa:chris-lea/node.js

Run updates:

sudo apt-get update

Install Node.js and Node Package Manager:

sudo apt-get install nodejs npm

If you need or want to compile Node C++ modules, then install nodejs-dev:

sudo apt-get install nodejs-dev

Installing Sourcemint and Cloud9 is highly recommended if you want to make your own Node.js modules.

On Ubuntu and other Linux systems, make sure that the libxml2-dev package is installed, or the installation of Cloud9 will fail:

sudo apt-get install libxml2-dev

Ensure that Sourcemint is installed globally:

npm install -g sm

Then, install Cloud9 with Sourcemint:

sm clone --dev https://github.com/ajaxorg/cloud9/tree/master cloud9

Or, install Cloud9 with Sourcemint after git cloning Cloud9 (you must have git installed and properly configured on your system, but you probably should have git anyways *smiley face*):

Git clone Cloud9:

git clone https://github.com/ajaxorg/cloud9.git cloud9

Switch to the Cloud9 clone directory:

cd cloud9

Use Sourcemint install in the Cloud9 clone directory:

sm install

Assuming that you already have a Drupal multi-site installation on the machine, you need to create a site-specific copy of the Drupal nodejs module folder. Typically in a multi-site installation, all contributed modules (like nodejs) are placed in the sites/all/modules folder. But, since you need a separate instance of nodejs.config.js and server.js for each site, copy the nodejs modules folder into a new modules folder in site, at /sites/[YourSiteName]/modules/nodejs. This new modules folder will live next to the files folder for each site.

Switch into the site folder for the site that you want to use nodejs with:

cd /var/www/drupal/sites/[YourSiteName]

Make a new modules directory, assuming you don't have other site-specific modules for this site already:

mkdir modules

Get a copy of the nodejs module and unpack it in the site-specific modules folder. Drush is probably the easiest, assuming you have it set up, or you can also wget. Remember to check the nodejs module page to get the link to the latest stable version.

Switch into the site-specific modules directory:

cd modules

Download the nodejs module tarball:

wget http://ftp.drupal.org/files/projects/nodejs-7.x-1.0.tar.gz[/prettify]

Unpack the tarball:

tar -xvzf nodejs-7.x-1.0.tar.gz

And, delete the tarball:

sudo rm nodejs-7.x-1.0.tar.gz

Then, switch into the new nodejs folder for the site:

cd nodejs

Now it starts to get exciting. In the new nodejs module folder, you need to install npm (for each and every site). This must be done in the site-specific nodejs module folder at /sites/[YourSiteName]/modules/nodejs, because the packages.json file must be present. Make sure you are in the site-specific nodejs module folder, and:

npm install

In the module folder, you will see many files, but you are only really concerned with one, nodejs.config.js.example, at this time. Go ahead and make a copy of it for your actual usage:

cp nodejs.config.js.example nodejs.config.js

Edit the nodejs.config.js file to work for your site. At the time of writing, there were several extra lines in the example config file that seemed to be actually preventing server.js from starting, so make sure that you have everything exact, or you won't get any love from server.js.

sudo nano nodejs.config.js

The default example file, below the commented instructions, is currently filled with the following:

settings = {
  scheme: 'http',
  port: 8080,
  host: 'localhost',
  resource: '/socket.io',
  serviceKey: '',
  backend: {
    port: 80,
    host: 'drupalhost',
    scheme: 'http',
    basePath: '',
    messagePath: '/nodejs/message'
  },
   debug: false,
   sslKeyPath: '',
   sslCertPath: '',
   baseAuthPath: '/nodejs/',
   publishUrl: 'publish',
   kickUserUrl: 'user/kick/:uid',
   logoutUserUrl: 'user/logout/:authtoken',
   addUserToChannelUrl: 'user/channel/add/:channel/:uid',
   removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
   addChannelUrl: 'channel/add/:channel',
   removeChannelUrl: 'channel/remove/:channel',
   setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
   addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
   removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
   toggleDebugUrl: 'debug/toggle',
   contentTokenUrl: 'content/token',
   publishMessageToContentChannelUrl: 'content/token/message',
   extensions: [],
   clientsCanWriteToChannels: false,
   clientsCanWriteToClients: false,
   transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
   jsMinification: true,
   jsEtag: true,
   logLevel: 1
};

But, I was having a lot of trouble getting server.js started, and noticed that the module configuration utility did not include many of these lines. After removing the lines I had much greater success:

   kickUserUrl: 'user/kick/:uid',
   logoutUserUrl: 'user/logout/:authtoken',
   addUserToChannelUrl: 'user/channel/add/:channel/:uid',
   removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
   addChannelUrl: 'channel/add/:channel',
   removeChannelUrl: 'channel/remove/:channel',
   setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
   addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
   removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
   toggleDebugUrl: 'debug/toggle',
   contentTokenUrl: 'content/token',
   publishMessageToContentChannelUrl: 'content/token/message',

In the end, you want it to look like this, with the local network IP address of your server ('localhost' didn't seem to work for me, nor did the local loopback, 127.0.0.1):

settings = {
  scheme: 'http',
  port: 8181,
  host: '192.168.1.10',
  resource: '/socket.io',
  serviceKey: 'YourServiceKey',
  backend: {
    port: 80,
    host: 'yoursitename.com',
    scheme: 'http',
    basePath: '',
    messagePath: '/nodejs/message'
  },
   debug: false,
   sslKeyPath: '',
   sslCertPath: '',
   baseAuthPath: '/nodejs/',
   publishUrl: 'publish',
   extensions: [],
   clientsCanWriteToChannels: false,
   clientsCanWriteToClients: false,
   transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
   jsMinification: true,
   jsEtag: true,
   logLevel: 1
};

A couple of notes.

  • 'resource' is definitely '/socket.io'
  • 'baseAuthPath is definitely '/nodejs/'
  • publishUrl is definitely 'publish' (not 'nodejs/publish' as specified by the config utility)

If you use a service key, then add to your site's settings.php file:

/**
 * Node.js service key:
 *
 */
$conf['nodejs_service_key'] = 'YourServiceKey';

After getting your nodejs.config.js file edited, start the nodejs instance by running in the site-specific module folder:

node server.js

Bonus: DrupalChat integration:

Copy the server extension out of the DrupalChat module folder:

sudo cp /var/www/drupal/sites/all/modules/drupalchat/drupalchat_nodejs/drupalchat_nodejs.server.extension.js /var/www/drupal/sites/[YourSiteName]/modules/nodejs/drupalchat_nodejs.server.extension.js

Add the extension to the nodejs.config.js file:

extensions: ['drupalchat_nodejs.server.extension.js']

Drupal version: 
Modules: 
Audience: 

Comments

moncler

I precisely had to thank you very much all over again. I am not sure the things I would've used without these concepts shown by you directly on such a subject. Completely was a difficult scenario in my view, however , being able to see the very well-written fashion you solved that forced me to weep for delight. I'm happy for the advice and even wish you recognize what a great job you're putting in training the others via your blog post. More than likely you've never encountered all of us.

michael kors handbags

I as well as my pals were checking the best guides from your website and quickly I had a horrible feeling I had not thanked the web blog owner for those secrets. Those boys ended up certainly passionate to read through them and have simply been making the most of them. I appreciate you for indeed being quite accommodating and for selecting some perfect themes most people are really desperate to be aware of. Our own sincere apologies for not saying thanks to earlier.

golden goose

I have to express my appreciation to you for rescuing me from this type of instance. Right after researching through the search engines and getting recommendations which are not productive, I assumed my life was gone. Living without the strategies to the problems you have solved by means of your entire short post is a crucial case, as well as those that could have badly affected my career if I hadn't come across the website. Your primary know-how and kindness in handling all the stuff was useful. I don't know what I would've done if I hadn't encountered such a solution like this. I am able to now look forward to my future. Thank you so much for the professional and sensible help. I won't be reluctant to propose your web blog to anybody who desires guidance on this matter.

converse outlet

I must convey my gratitude for your kindness in support of persons that have the need for guidance on this topic. Your real dedication to getting the message along ended up being pretty advantageous and have usually helped others just like me to arrive at their objectives. Your entire interesting instruction entails so much to me and a whole lot more to my fellow workers. Thanks a lot; from everyone of us.

kobe shoes

My spouse and i got now thrilled John could carry out his investigations from the precious recommendations he received in your web pages. It's not at all simplistic to just always be handing out secrets and techniques a number of people might have been selling. We take into account we've got the website owner to appreciate because of that. The specific explanations you made, the simple blog menu, the relationships your site assist to foster - it is all astonishing, and it is letting our son and our family reason why that situation is entertaining, which is certainly truly pressing. Thanks for all the pieces!

red bottom shoes

I would like to point out my passion for your generosity in support of individuals that actually need guidance on this one study. Your real dedication to getting the message along had been quite practical and has frequently made guys and women just like me to attain their dreams. Your new interesting guidelines can mean so much a person like me and still more to my office colleagues. Thanks a ton; from everyone of us.

jordans

I wish to show my appreciation to this writer for rescuing me from this particular scenario. Just after scouting through the internet and coming across advice which are not powerful, I assumed my life was done. Being alive without the presence of approaches to the issues you have fixed as a result of your entire article content is a crucial case, and the ones that might have adversely affected my entire career if I had not noticed your web site. Your own personal mastery and kindness in controlling all the details was priceless. I'm not sure what I would've done if I hadn't come across such a solution like this. I'm able to at this point relish my future. Thank you very much for your expert and effective guide. I won't hesitate to propose your web sites to anybody who requires recommendations about this topic.

converse shoes

I enjoy you because of your own efforts on this web page. My mom delights in doing investigations and it's really easy to see why. My spouse and i notice all of the powerful means you deliver very important tricks through your web blog and as well invigorate response from people on that article so my child is certainly being taught a lot. Take advantage of the remaining portion of the year. Your doing a remarkable job.

golden goose outlet

I wanted to write you the little note to give many thanks once again over the superb pointers you've discussed on this page. It was simply surprisingly open-handed of people like you to present easily what a lot of folks would've offered for sale for an electronic book to end up making some cash on their own, specifically now that you might well have tried it if you ever considered necessary. Those tips as well acted like a good way to be sure that the rest have the same passion like my very own to figure out very much more in respect of this problem. Certainly there are thousands of more enjoyable periods in the future for individuals who discover your website.

jordan 6

I am just commenting to let you know of the helpful discovery my friend's daughter gained visiting the blog. She even learned plenty of details, most notably how it is like to possess an excellent teaching style to have other folks easily thoroughly grasp some tricky subject areas. You actually did more than her desires. I appreciate you for showing these practical, trusted, edifying and even unique tips on the topic to Janet.

nike shoes for men

I have to express appreciation to this writer just for rescuing me from this type of matter. As a result of surfing through the the net and meeting thoughts which are not beneficial, I believed my entire life was well over. Existing without the strategies to the problems you've solved by way of the site is a serious case, as well as those which may have adversely affected my entire career if I hadn't come across your website. Your own mastery and kindness in touching every item was precious. I am not sure what I would have done if I hadn't come upon such a thing like this. I can also at this moment look forward to my future. Thanks for your time very much for the high quality and effective help. I won't be reluctant to endorse the sites to any individual who should have support on this subject matter.

Add new comment | arxic Drupal

great publish, very informative. I ponder why the
other specialists of this sector do not understand this.
You must continue your writing. I'm confident, you have a huge
readers' base already!

timberland outlet

I want to show my appreciation to the writer for bailing me out of this type of challenge. Because of looking out throughout the online world and seeing ideas which were not pleasant, I thought my life was gone. Being alive minus the solutions to the issues you've sorted out by means of the posting is a critical case, and ones that could have adversely damaged my career if I had not discovered your website. Your primary know-how and kindness in dealing with all the pieces was important. I am not sure what I would have done if I had not come upon such a step like this. I can also now look forward to my future. Thanks for your time so much for your impressive and sensible help. I won't be reluctant to endorse your web sites to any person who would like guidelines about this area.

nike sneakers

My wife and i ended up being quite happy Raymond could finish up his research through your ideas he discovered using your weblog. It is now and again perplexing to simply find yourself giving freely strategies that many men and women might have been selling. Therefore we grasp we have the writer to give thanks to for that. All of the explanations you've made, the easy website menu, the friendships you can help to engender - it's got all fabulous, and it is leading our son in addition to our family do think that topic is cool, which is certainly seriously fundamental. Thank you for everything!

Add new comment | arxic Drupal

Hi! I could have sworn I've been to your blog before but after looking at some of the articles I realized it's new to me.

Nonetheless, I'm certainly delighted I stumbled upon it and I'll
be bookmarking it and checking back often!

louboutin outlet

I precisely had to appreciate you yet again. I do not know what I might have sorted out in the absence of the entire suggestions shared by you over this subject matter. It became an absolute horrifying circumstance in my position, but being able to view your specialised technique you dealt with it made me to cry with delight. Now i'm happy for this work and in addition believe you recognize what a great job you are accomplishing educating many people all through a web site. Probably you have never met any of us.

Add new comment | arxic Drupal

I think this is one of the most significant info for me. And i am glad reading your article.
But want to remark on some general things, The site style is wonderful, the articles is really excellent :
D. Good job, cheers

off white jordan 1

I precisely wanted to thank you very much once more. I am not sure the things that I could possibly have done without the actual suggestions shared by you relating to such area. It absolutely was a frustrating situation for me, nevertheless taking a look at a skilled avenue you dealt with the issue made me to weep for contentment. I am happier for the information and in addition expect you recognize what a great job your are doing instructing men and women by way of your blog post. I am sure you've never encountered all of us.

Add new comment | arxic Drupal

Thank you for the auspicious writeup. It actually was once a enjoyment account it.
Look complicated to far introduced agreeable from you!
However, how can we keep up a correspondence?

supreme clothing

My spouse and i ended up being absolutely ecstatic that Raymond managed to carry out his research because of the ideas he made out of the blog. It's not at all simplistic just to continually be giving out steps that many a number of people may have been trying to sell. So we know we have got you to give thanks to for that. The main illustrations you have made, the straightforward blog navigation, the relationships your site aid to promote - it is many astounding, and it's facilitating our son and the family know that this content is entertaining, which is exceedingly pressing. Thank you for all!

Add new comment | arxic Drupal

Wow, amazing blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your website is great,
as well as the content!

golden goose

I intended to compose you one tiny remark so as to thank you so much as before about the spectacular suggestions you have documented on this page. It is certainly seriously open-handed with people like you to offer extensively what exactly most of us might have sold as an e-book to help make some dough for their own end, most importantly considering that you could have tried it in the event you desired. Those tricks in addition acted to become good way to be sure that many people have similar keenness much like my own to find out somewhat more in respect of this problem. I know there are some more enjoyable times in the future for folks who discover your site.

converse outlet

I must express my appreciation to you for rescuing me from this scenario. As a result of searching through the search engines and finding basics which were not powerful, I figured my life was done. Being alive minus the approaches to the issues you have fixed by means of your entire site is a crucial case, as well as the kind which might have adversely affected my entire career if I had not come across the website. Your actual know-how and kindness in maneuvering a lot of stuff was priceless. I am not sure what I would've done if I hadn't encountered such a subject like this. I can also now relish my future. Thanks a lot so much for the reliable and result oriented help. I will not hesitate to suggest your blog post to anybody who should have support about this subject.

Add new comment | arxic Drupal

Write more, thats all I have to say. Literally, it seems as though you relied on the
video to make your point. You obviously know what youre talking
about, why throw away your intelligence on just posting videos to your blog when you could be giving us something informative to read?

Add new comment | arxic Drupal

What i do not understood is if truth be told how you're not really a lot more well-favored than you
might be right now. You are so intelligent. You recognize therefore significantly in the case of this topic, made me
personally imagine it from numerous various angles. Its like men and women are not fascinated until it is
one thing to accomplish with Girl gaga! Your individual stuffs outstanding.

All the time deal with it up!

nike shoes

An fascinating dialogue is price comment. I feel that it is best to write more on this topic, it might not be a taboo topic but typically persons are not sufficient to speak on such topics. To the next. Cheers

Add new comment | arxic Drupal

I have been exploring for a bit for any high-quality articles or weblog posts on this sort
of house . Exploring in Yahoo I at last stumbled upon this site.
Studying this info So i'm happy to convey that I've a very just right
uncanny feeling I came upon just what I needed. I such a lot definitely will make certain to don?t fail to
remember this site and give it a glance on a
constant basis.

pg 1

After study just a few of the weblog posts on your website now, and I actually like your way of blogging. I bookmarked it to my bookmark web site list and can be checking again soon. Pls take a look at my website as well and let me know what you think.

Add new comment | arxic Drupal

This is the perfect site for anyone who really wants to understand this topic.
You realize a whole lot its almost hard to argue with you (not that I actually would want to…HaHa).

You certainly put a new spin on a topic that's been written about
for a long time. Wonderful stuff, just great!

Add new comment | arxic Drupal

It's remarkable to go to see this web page and reading the views of all
colleagues concerning this piece of writing, while I am also keen of getting know-how.

golden goose

I抎 have to examine with you here. Which is not something I usually do! I enjoy reading a put up that may make people think. Also, thanks for allowing me to comment!

Add new comment | arxic Drupal

Thank you for the good writeup. It in fact was
a amusement account it. Look advanced to more added agreeable
from you! However, how could we communicate?

yeezy shoes

Can I just say what a relief to seek out someone who actually knows what theyre talking about on the internet. You definitely know find out how to convey an issue to mild and make it important. Extra individuals have to read this and perceive this side of the story. I cant consider youre no more widespread because you undoubtedly have the gift.

Add new comment | arxic Drupal

Wow that was odd. I just wrote an extremely long comment but after I
clicked submit my comment didn't appear. Grrrr...
well I'm not writing all that over again. Regardless,
just wanted to say great blog!

calvin klein outlet

An fascinating discussion is price comment. I think that you should write more on this topic, it may not be a taboo topic but usually individuals are not sufficient to talk on such topics. To the next. Cheers

off white shoes

I and my guys came analyzing the best pointers on your web site while at once came up with a terrible feeling I never thanked the blog owner for those strategies. All of the women had been certainly stimulated to read through all of them and now have very much been taking pleasure in these things. Many thanks for being simply considerate and also for selecting variety of awesome ideas millions of individuals are really desirous to be informed on. Our honest regret for not saying thanks to you sooner.

Add new comment | arxic Drupal

Good web site you have got here.. It's difficult to find quality
writing like yours these days. I truly appreciate individuals like you!

Take care!!

fila shoes

I'm also commenting to let you understand what a amazing discovery my friend's child found viewing your site. She noticed so many details, including what it's like to have a great giving mood to get other folks with ease gain knowledge of specific extremely tough topics. You truly did more than people's desires. Thank you for presenting these warm and friendly, healthy, educational as well as easy thoughts on that topic to Emily.

Add new comment | arxic Drupal

It's in fact very difficult in this active life
to listen news on TV, therefore I only use world wide web
for that reason, and take the newest information.

yeezy

I intended to write you that bit of remark to help say thank you as before regarding the beautiful basics you have discussed in this article. It's simply wonderfully open-handed of you to supply extensively all a lot of folks might have advertised for an e book in order to make some money on their own, especially considering that you might have tried it if you ever considered necessary. These secrets likewise served to be a fantastic way to fully grasp that most people have a similar desire the same as my very own to understand way more with respect to this matter. I am certain there are lots of more fun opportunities up front for many who read through your site.

Add new comment | arxic Drupal

I was recommended this blog by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about
my difficulty. You are amazing! Thanks!

coach handbags

I really wanted to compose a small note to be able to thank you for all of the superb suggestions you are showing at this site. My extensive internet investigation has at the end of the day been paid with really good facts and strategies to talk about with my contacts. I would believe that most of us visitors are undoubtedly blessed to be in a great network with so many wonderful professionals with helpful basics. I feel very much fortunate to have discovered the web page and look forward to tons of more fabulous times reading here. Thanks a lot once more for a lot of things.

Add new comment | arxic Drupal

I have been browsing online greater than 3 hours these days, yet I never found any fascinating article like yours.
It is pretty worth enough for me. In my opinion, if all webmasters and bloggers made just right content material as you
probably did, the web will probably be a lot more
useful than ever before.

nike basketball shoes

I want to show my appreciation to you just for bailing me out of this particular trouble. As a result of browsing throughout the world wide web and getting concepts that were not powerful, I was thinking my entire life was done. Living minus the answers to the difficulties you have resolved as a result of your write-up is a crucial case, as well as ones that could have in a wrong way damaged my career if I had not encountered the website. Your training and kindness in controlling everything was very helpful. I am not sure what I would've done if I had not encountered such a step like this. I can now look forward to my future. Thanks so much for your specialized and amazing guide. I won't hesitate to endorse the website to anybody who needs and wants guidance on this topic.

Pages

Add new comment