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

coach factory outlet

I simply wanted to say thanks again. I'm not certain the things I would have taken care of in the absence of the entire solutions shared by you over my area. It truly was the scary matter in my opinion, but finding out your professional strategy you handled it made me to leap over fulfillment. I'm happy for your guidance and thus pray you comprehend what an amazing job you're carrying out teaching other individuals via your websites. More than likely you have never met any of us.

ferragamo belt

I wanted to type a brief note to be able to express gratitude to you for those stunning strategies you are giving out at this website. My considerable internet lookup has at the end been rewarded with brilliant facts and strategies to share with my good friends. I would repeat that most of us site visitors are undeniably endowed to dwell in a magnificent community with so many outstanding professionals with interesting tips and hints. I feel really blessed to have seen your entire web pages and look forward to many more entertaining moments reading here. Thanks a lot once more for everything.

kyrie 6

I and also my friends ended up analyzing the good tips and tricks from your website and so all of the sudden got an awful suspicion I had not thanked you for those tips. All the boys were totally passionate to read all of them and already have really been having fun with them. Thanks for being indeed thoughtful and also for making a choice on varieties of remarkable guides most people are really eager to be aware of. My personal honest apologies for not expressing appreciation to sooner.

golden goose

I as well as my pals appeared to be checking the good items on your web blog while suddenly I had a terrible feeling I had not expressed respect to the blog owner for those techniques. All the men were thrilled to read all of them and have in effect seriously been making the most of them. I appreciate you for getting indeed thoughtful as well as for going for this form of great useful guides millions of individuals are really eager to be informed on. My personal sincere apologies for not expressing appreciation to earlier.

calvin klein outlet

I needed to post you one bit of word to finally thank you so much over again on the breathtaking pointers you've contributed above. It's simply unbelievably generous of you to convey openly all that a few individuals could have marketed for an electronic book to get some bucks on their own, most importantly considering that you might have done it if you decided. The solutions also acted to become good way to be certain that many people have the identical zeal the same as mine to know more and more when it comes to this condition. I'm certain there are some more pleasant instances ahead for many who go through your blog.

golden goose sneakers

I and also my guys ended up digesting the nice tips located on the blog and quickly I got an awful feeling I never expressed respect to you for those secrets. The ladies were for that reason very interested to study all of them and have now in fact been taking advantage of those things. Thanks for truly being simply thoughtful and for finding this sort of wonderful useful guides most people are really desirous to know about. My honest regret for not expressing gratitude to you sooner.

nhl jerseys

A powerful share, I simply given this onto a colleague who was doing slightly analysis on this. And he the truth is bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to discuss this, I feel strongly about it and love studying extra on this topic. If doable, as you turn out to be experience, would you thoughts updating your blog with extra details? It's highly helpful for me. Huge thumb up for this weblog submit!

balenciaga

Aw, this was a really nice post. In thought I wish to put in writing like this additionally ?taking time and precise effort to make an excellent article?however what can I say?I procrastinate alot and under no circumstances appear to get something done.

kyrie 5

There are some interesting deadlines on this article but I don抰 know if I see all of them center to heart. There may be some validity but I will take hold opinion until I look into it further. Good article , thanks and we wish more! Added to FeedBurner as effectively

moncler jackets

After study just a few of the weblog posts in your web site now, and I really like your manner of blogging. I bookmarked it to my bookmark website list and will be checking again soon. Pls try my web page as well and let me know what you think.

balenciaga

Youre so cool! I dont suppose Ive read anything like this before. So good to search out any person with some authentic ideas on this subject. realy thank you for starting this up. this web site is something that's wanted on the web, someone with a little originality. helpful job for bringing something new to the internet!

supreme shirts

The next time I read a weblog, I hope that it doesnt disappoint me as much as this one. I imply, I do know it was my choice to learn, however I truly thought youd have one thing attention-grabbing to say. All I hear is a bunch of whining about something that you could possibly fix when you werent too busy searching for attention.

nike foamposite

I would like to point out my appreciation for your kindness in support of people who require assistance with the content. Your very own dedication to getting the solution throughout had become exceptionally beneficial and has made guys just like me to reach their pursuits. Your amazing important instruction can mean a whole lot to me and still more to my peers. Many thanks; from everyone of us.

timberland outlet

I am glad for commenting to let you be aware of what a fabulous discovery our child had checking the blog. She came to understand numerous pieces, with the inclusion of how it is like to have a wonderful giving style to let other folks smoothly understand various extremely tough matters. You undoubtedly exceeded our expected results. I appreciate you for distributing such necessary, safe, revealing and as well as easy thoughts on that topic to Tanya.

yeezy

I not to mention my buddies have been looking at the good key points located on your web site and then then I got a terrible suspicion I never thanked the website owner for those techniques. All of the people became consequently passionate to see all of them and have now actually been making the most of them. Thank you for actually being simply thoughtful as well as for making a choice on such amazing areas most people are really wanting to discover. My very own sincere regret for not expressing gratitude to you sooner.

fila shoes

I needed to write you that little bit of note to give many thanks over again relating to the beautiful guidelines you have documented on this page. This is simply extremely open-handed with you in giving extensively what exactly most of us could have made available as an e book to make some cash for their own end, mostly since you might have tried it in case you considered necessary. These strategies also worked to provide a good way to recognize that other individuals have similar desire like my own to realize a lot more with reference to this problem. I am sure there are many more pleasant situations ahead for many who looked at your blog.

yeezy boost 350

I precisely desired to appreciate you again. I am not sure what I might have carried out without the entire tips and hints discussed by you directly on such area of interest. It was before a real hard dilemma in my opinion, however , looking at this well-written avenue you solved that forced me to weep for contentment. I am happier for this information and as well , have high hopes you realize what a great job your are doing instructing the others via a blog. I am sure you've never got to know all of us.

chrome hearts online

I am commenting to let you be aware of what a outstanding discovery our princess enjoyed viewing your web page. She picked up a wide variety of things, most notably what it's like to have a marvelous coaching style to let most people really easily know certain complicated subject areas. You truly did more than her expectations. Thank you for supplying those interesting, dependable, informative and in addition easy thoughts on the topic to Emily.

yeezy boost 350

My spouse and i got really excited that Louis managed to deal with his inquiry with the precious recommendations he received out of the web page. It's not at all simplistic to simply choose to be giving freely points that many other folks might have been making money from. We do know we have the blog owner to thank for this. The illustrations you made, the simple website navigation, the friendships your site make it possible to engender - it's got most fabulous, and it's really helping our son in addition to our family reason why the subject matter is awesome, and that's highly important. Thanks for all!

jordan shoes

A lot of thanks for your entire effort on this site. My aunt take interest in participating in internet research and it's easy to see why. A number of us know all regarding the dynamic way you give both useful and interesting steps via this website and even foster participation from visitors about this matter plus our favorite daughter is without question discovering a great deal. Take advantage of the rest of the year. You're the one conducting a pretty cool job.

lebron 15 shoes

I want to express some appreciation to the writer for rescuing me from this circumstance. Right after exploring throughout the online world and finding advice which were not pleasant, I believed my entire life was well over. Existing minus the strategies to the issues you've resolved by way of your main guide is a serious case, and those which may have adversely damaged my entire career if I hadn't discovered your site. Your primary capability and kindness in taking care of all areas was vital. I don't know what I would have done if I had not come across such a solution like this. It's possible to at this time look ahead to my future. Thanks very much for this reliable and results-oriented guide. I won't be reluctant to propose your web site to any person who requires assistance about this problem.

nike kyrie 5

I and my friends were taking note of the nice strategies found on your website and so immediately I got a terrible suspicion I had not thanked the site owner for those secrets. My boys were definitely for this reason happy to read through them and have in truth been enjoying them. Appreciate your indeed being quite accommodating as well as for settling on such exceptional tips millions of individuals are really eager to know about. My very own sincere apologies for not expressing gratitude to earlier.

cheap jordans

I just wanted to type a simple comment to be able to express gratitude to you for some of the unique ways you are sharing here. My extended internet research has at the end of the day been paid with pleasant facts and strategies to talk about with my visitors. I would admit that we visitors actually are unequivocally fortunate to dwell in a fabulous place with so many wonderful professionals with valuable secrets. I feel very much lucky to have encountered your webpage and look forward to plenty of more pleasurable moments reading here. Thanks once again for everything.

air max 97

You made some respectable factors there. I seemed on the internet for the difficulty and found most people will go together with together with your website.

air max 95

It is best to take part in a contest for among the best blogs on the web. I will advocate this site!

yeezy

A powerful share, I simply given this onto a colleague who was doing slightly analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love studying more on this topic. If attainable, as you turn into experience, would you thoughts updating your blog with more particulars? It's highly helpful for me. Huge thumb up for this blog post!

nike air max

Aw, this was a very nice post. In thought I wish to put in writing like this additionally ?taking time and precise effort to make an excellent article?but what can I say?I procrastinate alot and in no way appear to get something done.

fitflop

I discovered your weblog web site on google and verify a few of your early posts. Proceed to maintain up the superb operate. I simply additional up your RSS feed to my MSN News Reader. Searching for forward to reading extra from you afterward!?

hogan outlet

I and also my buddies were found to be viewing the great information from your web blog and then all of the sudden I got a terrible feeling I had not expressed respect to the web site owner for those tips. All the guys had been consequently stimulated to learn all of them and already have really been having fun with them. Many thanks for getting quite considerate and then for choosing varieties of marvelous things most people are really desirous to be informed on. Our honest apologies for not saying thanks to you sooner.

yeezy 700

I am just commenting to make you understand what a remarkable discovery my wife's child experienced reading through yuor web blog. She mastered many issues, which included what it's like to possess an excellent coaching heart to get a number of people without problems understand a number of problematic topics. You really did more than our own expectations. I appreciate you for producing such insightful, healthy, explanatory as well as easy tips about this topic to Mary.

nike shoes

I have to get across my respect for your kind-heartedness supporting folks that absolutely need guidance on the issue. Your very own dedication to passing the message all around became extremely helpful and has all the time enabled many people like me to realize their dreams. Your insightful advice denotes a great deal a person like me and much more to my office workers. Regards; from each one of us.

cheap jordans

I would like to show appreciation to this writer just for bailing me out of this instance. After checking through the search engines and getting proposals that were not helpful, I thought my life was gone. Living devoid of the strategies to the problems you've solved by means of this short post is a critical case, and those which may have in a negative way affected my career if I hadn't noticed the website. Your personal skills and kindness in handling all areas was priceless. I am not sure what I would've done if I had not encountered such a solution like this. I can also now look ahead to my future. Thanks for your time so much for this reliable and effective help. I won't be reluctant to refer your site to anybody who should get guidance about this situation.

goyard handbags

I want to show my admiration for your generosity supporting visitors who absolutely need guidance on this theme. Your special dedication to passing the solution around ended up being pretty significant and have all the time helped employees much like me to arrive at their aims. The warm and friendly instruction entails this much to me and a whole lot more to my mates. Thanks a lot; from everyone of us.

bape hoodie

I happen to be writing to let you understand what a impressive experience my friend's girl found studying your webblog. She mastered a good number of pieces, most notably what it is like to have a wonderful giving mood to get the rest effortlessly gain knowledge of a number of multifaceted subject areas. You really surpassed our own expectations. Thank you for churning out these powerful, trustworthy, educational and also easy tips on this topic to Jane.

salvatore ferragamo belt

I enjoy you because of all of your hard work on this web page. Ellie enjoys managing internet research and it is obvious why. Most people notice all regarding the lively method you present insightful guidelines via the website and as well as increase response from some others on this concept so our favorite simple princess is without question studying so much. Take pleasure in the rest of the new year. You are doing a pretty cool job.

nike foamposite

A lot of thanks for your own work on this site. Gloria take interest in doing internet research and it's really simple to grasp why. Many of us hear all concerning the dynamic ways you produce insightful items by means of the blog and as well as welcome participation from others on the subject plus my child is undoubtedly starting to learn a whole lot. Have fun with the remaining portion of the new year. You are always carrying out a glorious job.

michael kors

I am just commenting to let you understand of the excellent discovery my friend's child experienced checking your blog. She came to find such a lot of pieces, not to mention what it is like to have an incredible giving nature to let others effortlessly know precisely some extremely tough things. You undoubtedly exceeded our own desires. Thank you for giving those practical, healthy, revealing as well as fun tips on that topic to Janet.

nike air max 2017

Youre so cool! I dont suppose Ive read something like this before. So nice to seek out somebody with some original ideas on this subject. realy thank you for starting this up. this web site is one thing that's needed on the internet, someone with somewhat originality. useful job for bringing something new to the internet!

yeezy shoes

It抯 onerous to search out knowledgeable individuals on this topic, however you sound like you already know what you抮e speaking about! Thanks

supreme

Spot on with this write-up, I really think this web site wants much more consideration. I抣l probably be again to read far more, thanks for that info.

kd 12 shoes

I抦 impressed, I have to say. Actually not often do I encounter a blog that抯 each educative and entertaining, and let me inform you, you have got hit the nail on the head. Your idea is outstanding; the problem is something that not enough persons are speaking intelligently about. I am very pleased that I stumbled throughout this in my search for one thing relating to this.

Pages

Add new comment