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 simply wished to say thanks yet again. I'm not certain what I could possibly have followed without the type of tactics discussed by you about such subject. Entirely was a very frustrating scenario in my position, nevertheless spending time with the specialized approach you handled that took me to jump over gladness. Now i'm happier for your support and as well , hope that you find out what a great job you're doing teaching people via your blog post. I'm certain you haven't encountered all of us.

salvatore ferragamo belt

Thank you a lot for giving everyone remarkably memorable opportunity to check tips from this site. It is always so beneficial and jam-packed with a great time for me personally and my office fellow workers to search your web site not less than 3 times per week to see the new things you will have. Of course, I'm so at all times amazed for the splendid concepts you give. Selected two areas on this page are certainly the simplest I have had.

nike air vapormax

I would like to point out my respect for your kindness for individuals who have the need for guidance on the subject matter. Your personal commitment to getting the message all around has been incredibly beneficial and have surely encouraged employees like me to achieve their endeavors. Your own insightful suggestions denotes so much a person like me and even more to my office workers. Many thanks; from everyone of us.

yeezy shoes

Needed to send you one bit of observation to finally thank you yet again relating to the superb guidelines you have provided on this page. It's really pretty generous of you to give unreservedly precisely what a number of us could have offered for an ebook in order to make some money for themselves, mostly now that you could have done it if you ever considered necessary. Those strategies additionally served to be the good way to be aware that many people have similar eagerness the same as mine to know the truth lots more with regard to this issue. Certainly there are thousands of more pleasant opportunities ahead for individuals who take a look at your blog post.

yeezy shoes

I would like to get across my respect for your kindness for men and women that must have assistance with in this area. Your very own dedication to getting the message all-around had been definitely good and has specifically enabled men and women like me to realize their endeavors. Your amazing invaluable useful information can mean much to me and somewhat more to my mates. With thanks; from each one of us.

moncler outlet

I simply wanted to send a small message in order to say thanks to you for all of the amazing tips and tricks you are giving out on this site. My time consuming internet look up has finally been paid with pleasant facts and strategies to go over with my pals. I would say that most of us website visitors are extremely lucky to exist in a superb network with so many outstanding individuals with very helpful advice. I feel pretty grateful to have seen the webpage and look forward to some more amazing minutes reading here. Thanks a lot once again for everything.

converse outlet

I intended to draft you one little bit of note just to give thanks once again on your great knowledge you have provided on this website. It was really incredibly generous with you giving unreservedly what a lot of folks could have offered as an electronic book to help make some bucks for their own end, specifically now that you could possibly have done it if you desired. These smart ideas additionally acted to become a great way to know that the rest have a similar desire similar to my own to figure out a lot more related to this problem. I'm sure there are thousands of more pleasant sessions up front for those who read through your website.

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.

hermes belts for men

I and my pals appeared to be studying the best recommendations on your web site while unexpectedly I had a terrible feeling I never expressed respect to the web blog owner for those techniques. Most of the boys were for that reason excited to learn them and have in fact been using these things. Thanks for getting really considerate and also for making a decision on this kind of impressive subject matter millions of individuals are really wanting to be informed on. My honest regret for not saying thanks to earlier.

yeezy boost 350 v2

I would like to express my love for your generosity supporting persons who need guidance on this one matter. Your real commitment to getting the message along was incredibly interesting and have really made men and women much like me to achieve their endeavors. Your new helpful key points can mean this much a person like me and even further to my peers. Thanks a ton; from everyone of us.

golden goose

I'm also writing to let you be aware of of the great discovery our child had reading yuor web blog. She came to find many pieces, which included what it is like to have an excellent teaching heart to make the rest quite simply learn about chosen complex matters. You truly did more than our own expected results. I appreciate you for delivering the essential, safe, revealing and even fun thoughts on that topic to Jane.

lebron 17

I actually wanted to send a message to be able to thank you for all the magnificent suggestions you are writing on this website. My long internet investigation has at the end been rewarded with excellent know-how to talk about with my company. I would claim that we site visitors are very much fortunate to exist in a very good site with very many brilliant people with good hints. I feel very much happy to have come across your entire website and look forward to really more fabulous moments reading here. Thank you once again for a lot of things.

converse shoes

I and also my friends have already been reading through the best solutions located on the blog and so quickly developed an awful feeling I never thanked the web site owner for those techniques. Those young men happened to be consequently glad to read them and have now definitely been tapping into those things. Appreciation for actually being very considerate and for pick out these kinds of really good topics millions of individuals are really wanting to understand about. My very own sincere regret for not expressing appreciation to you earlier.

kd 11 shoes

I intended to put you that bit of word just to thank you yet again regarding the lovely secrets you have discussed above. It is simply unbelievably open-handed of people like you to provide publicly precisely what a few people could possibly have marketed for an e-book in order to make some bucks for their own end, certainly given that you might have done it in case you decided. Those suggestions likewise acted like the great way to recognize that other people have the same fervor really like my personal own to know the truth whole lot more in respect of this condition. I'm certain there are many more enjoyable occasions in the future for individuals that check out your blog.

off white hoodie

I wish to express appreciation to the writer just for rescuing me from such a predicament. Because of scouting through the world wide web and seeing proposals which are not productive, I thought my life was over. Living without the strategies to the problems you've fixed by way of this short post is a critical case, as well as ones which could have badly affected my career if I had not discovered your web site. The mastery and kindness in controlling every item was helpful. I am not sure what I would have done if I hadn't encountered such a step like this. It's possible to at this moment look forward to my future. Thank you very much for the professional and sensible guide. I won't think twice to endorse your site to any individual who would need guidance on this topic.

golden goose outlet

I and also my friends happened to be going through the excellent thoughts from your website and then suddenly I had an awful suspicion I had not thanked the web site owner for those secrets. The young men became totally happy to learn them and now have certainly been having fun with these things. Thanks for simply being really considerate and for picking this sort of nice subjects most people are really wanting to learn about. Our honest regret for not expressing gratitude to earlier.

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.

Pages

Add new comment