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

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.

golden goose sneakers

I must show some thanks to the writer just for bailing me out of this scenario. As a result of exploring through the internet and finding tricks which are not powerful, I thought my entire life was done. Being alive devoid of the strategies to the difficulties you've sorted out all through your main posting is a crucial case, as well as the kind which might have negatively damaged my career if I hadn't encountered your site. The ability and kindness in taking care of the whole thing was very useful. I'm not sure what I would've done if I hadn't come across such a subject like this. I'm able to at this time look forward to my future. Thanks very much for your skilled and results-oriented guide. I won't think twice to refer the website to anybody who desires guide about this situation.

air max 270

I want to show some appreciation to this writer for rescuing me from this type of condition. After browsing throughout the world-wide-web and meeting concepts which are not beneficial, I assumed my entire life was well over. Living without the presence of answers to the issues you have sorted out by way of this review is a critical case, as well as ones which could have adversely damaged my career if I hadn't encountered the blog. That know-how and kindness in controlling every aspect was very useful. I don't know what I would have done if I had not come upon such a subject like this. I am able to at this moment look ahead to my future. Thanks very much for your specialized and sensible guide. I won't hesitate to endorse your blog post to anybody who desires guidelines about this topic.

lebron shoes

I have to show thanks to you just for rescuing me from such a challenge. As a result of exploring throughout the world wide web and finding tips which are not helpful, I was thinking my entire life was well over. Existing minus the solutions to the issues you have resolved as a result of the website is a critical case, and those that would have in a negative way damaged my career if I had not come across your site. Your primary natural talent and kindness in dealing with everything was tremendous. I am not sure what I would've done if I hadn't encountered such a subject like this. It's possible to at this time look forward to my future. Thanks for your time so much for your skilled and results-oriented help. I will not be reluctant to refer your web page to anybody who needs tips on this area.

hermes bag

Thank you so much for providing individuals with remarkably brilliant opportunity to read articles and blog posts from this site. It is usually so pleasurable plus stuffed with a great time for me personally and my office peers to visit your site at least thrice in one week to see the fresh issues you have. And of course, we're actually satisfied concerning the breathtaking points you serve. Selected 4 facts in this posting are really the simplest we have all ever had.

supreme clothing

Thank you a lot for giving everyone an extremely remarkable opportunity to read from this site. It can be so cool and as well , jam-packed with fun for me personally and my office friends to search the blog no less than 3 times in a week to learn the new secrets you will have. Not to mention, I'm usually impressed considering the powerful creative concepts served by you. Certain 1 areas in this posting are honestly the most impressive I've ever had.

kyrie 5

I actually wanted to send a message to be able to say thanks to you for some of the wonderful secrets you are posting on this site. My particularly long internet search has at the end been paid with excellent information to share with my two friends. I would assert that many of us website visitors actually are quite fortunate to dwell in a great network with many marvellous people with great tricks. I feel very much privileged to have encountered the web site and look forward to plenty of more brilliant minutes reading here. Thanks a lot once more for a lot of things.

supreme clothing

Thank you so much for providing individuals with an extraordinarily splendid opportunity to discover important secrets from here. It's always so ideal plus packed with amusement for me personally and my office fellow workers to visit the blog not less than three times a week to learn the fresh secrets you have got. And of course, I am also always fulfilled with your remarkable techniques you serve. Certain 2 ideas in this posting are basically the finest we've ever had.

nike air max95

I precisely had to thank you very much once again. I am not sure the things that I would have accomplished without the entire concepts shared by you about this area of interest. It was before a real scary matter in my circumstances, but encountering this specialized technique you treated that made me to cry with happiness. I will be thankful for this service and even sincerely hope you really know what a great job you were accomplishing instructing others through the use of your webblog. Most probably you haven't got to know all of us.

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.

longchamp

Aw, this was a very nice post. In concept I want to put in writing like this moreover ?taking time and actual effort to make an excellent article?however what can I say?I procrastinate alot and by no means appear to get one thing done.

chrome hearts

I want to show my thanks to this writer just for bailing me out of this particular trouble. As a result of checking through the world wide web and obtaining tricks which are not powerful, I believed my entire life was over. Living devoid of the strategies to the issues you've sorted out by way of your good review is a crucial case, and the kind that would have negatively damaged my career if I had not encountered the website. Your main capability and kindness in dealing with all things was priceless. I'm not sure what I would have done if I had not come upon such a thing like this. It's possible to at this moment look forward to my future. Thanks a lot so much for your reliable and effective guide. I won't hesitate to refer the website to anyone who should get guidance on this subject matter.

supreme outlet

I precisely had to thank you so much again. I am not sure the things that I would have carried out in the absence of these hints contributed by you on that situation. This has been the horrifying setting for me personally, however , viewing the very skilled style you solved it made me to leap over delight. I am just thankful for the help and as well , expect you find out what an amazing job you have been getting into training others through a site. Probably you've never met all of us.

moncler jackets

I am glad for writing to make you be aware of what a exceptional encounter my wife's daughter gained going through your site. She figured out a wide variety of details, which included what it is like to have an incredible giving nature to let men and women clearly completely grasp specified very confusing subject matter. You actually exceeded people's expectations. Many thanks for presenting those invaluable, healthy, informative as well as cool tips about the topic to Kate.

supreme clothing

I enjoy you because of your whole labor on this web page. My niece loves carrying out investigations and it is easy to see why. We learn all about the compelling means you offer functional strategies by means of your web site and as well as strongly encourage participation from the others on this subject matter while our simple princess is truly becoming educated a great deal. Enjoy the rest of the new year. You're the one conducting a pretty cool job.

calvin klein underwear

I want to show my thanks to you for bailing me out of this particular condition. Right after exploring through the world-wide-web and meeting strategies which are not powerful, I was thinking my life was well over. Being alive without the solutions to the issues you have resolved as a result of this blog post is a serious case, as well as those which could have adversely damaged my entire career if I had not noticed your web blog. Your skills and kindness in touching all areas was excellent. I am not sure what I would have done if I had not come upon such a solution like this. I'm able to now look forward to my future. Thanks for your time so much for the impressive and amazing help. I will not be reluctant to recommend your web page to anyone who would need guidance on this problem.

chrome hearts store

Thank you for each of your work on this site. My mum really likes doing internet research and it's simple to grasp why. Most of us notice all concerning the powerful form you convey good suggestions on this web blog and in addition increase response from website visitors about this subject so our own daughter is in fact learning a whole lot. Have fun with the remaining portion of the year. You're the one performing a great job.

hermes handbags

I simply wished to say thanks yet again. I do not know what I might have implemented in the absence of the entire basics discussed by you over my field. It has been a very traumatic concern for me personally, nevertheless taking note of this skilled tactic you processed it made me to weep over delight. Now i'm thankful for the information and as well , have high hopes you comprehend what an amazing job you have been doing instructing many people using a blog. Probably you've never met all of us.

christian louboutin shoes

My spouse and i got glad when Emmanuel managed to finish off his researching through the entire precious recommendations he received using your site. It is now and again perplexing to simply happen to be giving out instructions men and women have been selling. We really keep in mind we now have the writer to give thanks to for that. These illustrations you made, the simple site navigation, the friendships your site help to instill - it's most excellent, and it's helping our son and our family believe that this situation is pleasurable, which is quite essential. Many thanks for the whole lot!

cheap jordans

I'm writing to let you be aware of of the excellent encounter my cousin's daughter found studying the blog. She discovered numerous details, including what it is like to have an ideal helping character to make other individuals effortlessly learn specific extremely tough issues. You truly exceeded our desires. Thanks for coming up with such invaluable, safe, revealing and in addition easy guidance on this topic to Sandra.

air jordan shoes

I actually wanted to write down a quick message to be able to express gratitude to you for those great secrets you are placing here. My time consuming internet look up has at the end of the day been honored with beneficial concept to exchange with my family members. I would declare that many of us site visitors actually are truly fortunate to dwell in a perfect network with many brilliant people with interesting plans. I feel rather lucky to have encountered your website and look forward to plenty of more pleasurable times reading here. Thanks a lot once again for all the details.

kate spade outlet

I actually wanted to type a brief comment to say thanks to you for the unique recommendations you are giving out here. My time consuming internet look up has now been recognized with wonderful facts and techniques to talk about with my friends and family. I 'd declare that most of us visitors actually are undeniably blessed to live in a decent network with so many brilliant people with valuable suggestions. I feel truly privileged to have encountered your entire web page and look forward to really more awesome moments reading here. Thanks once again for all the details.

off-white

I as well as my friends were actually reading the best tips and tricks found on your web blog while before long developed an awful feeling I had not expressed respect to the website owner for those tips. The young men became as a result joyful to read them and already have extremely been enjoying those things. We appreciate you truly being really accommodating and then for making a choice on this kind of superior subject areas most people are really desperate to understand about. My personal sincere apologies for not expressing appreciation to you sooner.

yeezy shoes

I intended to post you the tiny word to finally give thanks as before relating to the amazing basics you've discussed here. It is so pretty open-handed of you to give unhampered all that a few people could possibly have advertised as an e book to end up making some bucks on their own, mostly since you might have done it if you wanted. Those ideas likewise worked to be the fantastic way to be sure that the rest have similar keenness just like my personal own to know the truth great deal more in terms of this problem. I know there are a lot more pleasant situations up front for folks who check out your blog.

moncler

I'm commenting to make you know what a remarkable discovery our girl developed checking yuor web blog. She noticed a lot of things, with the inclusion of how it is like to have an amazing helping heart to let certain people clearly grasp some advanced subject matter. You undoubtedly exceeded my expected results. I appreciate you for providing those invaluable, safe, explanatory and even cool guidance on that topic to Janet.

nike air max shoes

I together with my buddies ended up following the nice secrets on your web blog and instantly came up with an awful suspicion I had not thanked the web blog owner for those secrets. The guys became for that reason very interested to read them and now have extremely been tapping into these things. Appreciate your turning out to be indeed helpful and then for figuring out this kind of superior tips millions of individuals are really desirous to know about. My personal honest regret for not expressing appreciation to you sooner.

supreme clothing

Thanks so much for providing individuals with an exceptionally special possiblity to read critical reviews from here. It's always so superb plus full of a great time for me personally and my office co-workers to search the blog at a minimum thrice in a week to read the fresh issues you will have. And indeed, we're at all times motivated concerning the incredible tactics you give. Certain 3 points in this article are completely the most effective we have all ever had.

louboutin shoes

When I originally commented I clicked the -Notify me when new comments are added- checkbox and now every time a remark is added I get 4 emails with the same comment. Is there any way you may take away me from that service? Thanks!

golden goose outlet

Aw, this was a very nice post. In idea I want to put in writing like this additionally ?taking time and actual effort to make an excellent article?however what can I say?I procrastinate alot and on no account seem to get one thing done.

nike air max 97

A powerful share, I just given this onto a colleague who was doing a bit evaluation on this. And he in truth purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I really feel strongly about it and love studying more on this topic. If doable, as you turn into expertise, would you mind updating your weblog with extra particulars? It is extremely useful for me. Big thumb up for this weblog submit!

kd 11 shoes

Good post. I study something more challenging on different blogs everyday. It will all the time be stimulating to learn content from different writers and follow a little something from their store. I抎 prefer to use some with the content material on my blog whether you don抰 mind. Natually I抣l provide you with a link in your internet blog. Thanks for sharing.

jordan shoes

Youre so cool! I dont suppose Ive learn something like this before. So nice to seek out someone with some original ideas on this subject. realy thanks for beginning this up. this web site is something that's needed on the internet, someone with a little bit originality. useful job for bringing something new to the web!

yeezy shoes

There may be noticeably a bundle to find out about this. I assume you made sure nice points in features also.

jordan 12

Thanks for all of the efforts on this web page. Betty enjoys getting into research and it's really easy to understand why. I hear all of the dynamic mode you convey helpful guidance through the web site and as well as invigorate contribution from other ones about this concept so our own girl is without a doubt being taught a lot. Take pleasure in the rest of the new year. You have been performing a useful job.

nike air vapormax

I intended to draft you this very little note to be able to say thank you the moment again considering the extraordinary things you've contributed on this site. It is tremendously open-handed with people like you to allow freely all that a number of people would have marketed for an ebook to get some dough for their own end, primarily seeing that you could possibly have tried it if you ever considered necessary. Those points in addition acted like a easy way to be certain that some people have the identical desire much like mine to realize more concerning this issue. I think there are lots of more enjoyable times ahead for many who check out your blog.

michael kors outlet

My spouse and i were very relieved that Michael could deal with his research because of the precious recommendations he acquired through the weblog. It's not at all simplistic just to choose to be giving freely concepts which often other folks could have been making money from. And we fully grasp we have the blog owner to thank for that. The specific illustrations you have made, the easy web site navigation, the relationships you make it possible to foster - it's got all fabulous, and it is helping our son and our family know that this article is pleasurable, which is really serious. Thank you for all!

kyrie 3

My wife and i were happy John could carry out his researching because of the ideas he got from your own web site. It is now and again perplexing just to possibly be making a gift of hints that some people could have been selling. We keep in mind we've got the blog owner to be grateful to because of that. All of the explanations you've made, the easy blog menu, the friendships your site aid to foster - it's got mostly awesome, and it is aiding our son and the family do think this content is pleasurable, which is certainly exceptionally fundamental. Thanks for the whole thing!

golden goose outlet

Needed to post you the tiny remark in order to give many thanks over again considering the beautiful ideas you've featured here. This has been quite particularly generous of you to supply openly what many of us would have distributed for an e book to earn some cash on their own, chiefly considering the fact that you might have tried it in the event you decided. Those advice in addition worked like a fantastic way to fully grasp some people have the identical interest similar to my personal own to grasp significantly more related to this problem. I'm certain there are lots of more enjoyable instances in the future for those who look into your site.

yeezy boost 350 v2

I simply desired to say thanks once more. I am not sure the things I could possibly have used without the actual hints revealed by you about that subject. It has been a horrifying circumstance for me, nevertheless looking at the very specialised technique you resolved the issue made me to weep for happiness. I am grateful for your help and then pray you realize what an amazing job you are getting into instructing most people with the aid of your site. I am certain you haven't encountered all of us.

yeezy shoes

I want to express thanks to this writer just for bailing me out of such a challenge. After scouting throughout the the web and getting principles which were not powerful, I assumed my life was well over. Existing devoid of the strategies to the difficulties you have fixed all through your short post is a crucial case, as well as ones which might have negatively damaged my entire career if I had not encountered your blog post. Your primary ability and kindness in controlling a lot of stuff was very useful. I'm not sure what I would've done if I hadn't come upon such a thing like this. I am able to at this point look forward to my future. Thanks a lot very much for your professional and amazing help. I will not think twice to recommend your blog to any individual who needs and wants guidance about this matter.

Pages

Add new comment