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

1080pxvideos

"Enough!" He (I presumed) walked up to me, demonstrating that I had a head of height in advantage, and gestured imperiously for Bekhat to move away from me. Given the circumstances, what could she do but obey? As she did so, a pair of the brutes moved from their line to flank her, though they did nothing more.
http://health-nutritionblog.com/__media__/js/netsoltrademark.php?d=1080p...
The little man drew from one sleeve a small stick, looking as though he had pulled it from a bush to scrape his teeth on his way over, and dragged it along the ground in a circle around me. As he completed the circle he spat on the joining and straightened again.
http://autoinsure.com/__media__/js/netsoltrademark.php?d=1080pxvideos.co... http://tractor1.com/__media__/js/netsoltrademark.php?d=1080pxvideos.com/... http://champagne-roederer.us/__media__/js/netsoltrademark.php?d=1080pxvi... https://got4x4.com/source/1080pxvideos.com/en/category/169/69/popular/1/ http://bharatpages.in/l.php?url=http://1080pxvideos.com/en/category/94/T... http://klamathbasin.net/__media__/js/netsoltrademark.php?d=1080pxvideos.... http://urbansurvival101.com/__media__/js/netsoltrademark.php?d=1080pxvid... http://asobox2.s3.valueserver.jp/www.mori-o-hashirou.com/o/CT/visit.php?... http://www.slcourts.com/__media__/js/netsoltrademark.php?d=1080pxvideos.... http://hawkinsfamilyoffice.com/__media__/js/netsoltrademark.php?d=1080px... http://msbank.info/__media__/js/netsoltrademark.php?d=1080pxvideos.com/e... http://dragonpig.com/__media__/js/netsoltrademark.php?d=1080pxvideos.com... http://jesuschrist.ru/chat/redir.php?url=https://1080pxvideos.com/en/cat... http://wineryclassifieds.com/__media__/js/netsoltrademark.php?d=1080pxvi... http://www.m-station.com/__media__/js/netsoltrademark.php?d=1080pxvideos... http://dorothyyep.com/__media__/js/netsoltrademark.php?d=1080pxvideos.co... http://izmail-tour.com/engine/redirect.php?url=http://1080pxvideos.com/e... https://www.guestbookking.com/cgi-bin/host/firebook.cgi?account=5050&act...
I grew alarmed as he drew a small knife from somewhere or other, but he only cut his own finger and splashed a few drops on to the dust. "Now, creature," he said, looking me in the eyes at last. "Simply walk over my circle, return to your home, prove me wrong, and we shall trouble you no more."

nike off whtie

I must show my admiration for your generosity in support of folks who really want help with that concern. Your personal commitment to getting the solution around appears to be exceptionally good and has continuously helped professionals just like me to reach their desired goals. Your new invaluable tips and hints means a whole lot to me and still more to my fellow workers. Thanks a ton; from all of us.

Add new comment | arxic Drupal

Thank you for every other informative website. Where else may just
I get that type of information written in such a perfect way?
I have a mission that I'm just now operating on, and I have been on the glance
out for such info.

Add new comment | arxic Drupal

You really make it seem so easy with your presentation but I find this matter to
be actually something that I think I would never understand.

It seems too complicated and extremely broad for me.
I am looking forward for your next post, I'll
try to get the hang of it!

nfl jerseys

An interesting dialogue is value comment. I think that it is best to write more on this subject, it might not be a taboo subject but generally individuals are not sufficient to speak on such topics. To the next. Cheers

Add new comment | arxic Drupal

I have to thank you for the efforts you've put in penning
this website. I really hope to view the same high-grade content from
you in the future as well. In fact, your creative writing abilities has encouraged me to
get my very own blog now ;)

off white

Can I simply say what a reduction to search out someone who really is aware of what theyre speaking about on the internet. You definitely know find out how to deliver a difficulty to light and make it important. Extra individuals must learn this and understand this aspect of the story. I cant believe youre not more in style since you positively have the gift.

Add new comment | arxic Drupal

I am curious to find out what blog platform you happen to be utilizing?
I'm experiencing some minor security issues with my latest website
and I would like to find something more safeguarded. Do you have any suggestions?

nike air max

I抎 must examine with you here. Which is not something I normally do! I take pleasure in reading a publish that will make individuals think. Also, thanks for allowing me to remark!

converse shoes

I抎 need to verify with you here. Which isn't something I normally do! I get pleasure from studying a post that will make people think. Additionally, thanks for permitting me to comment!

supreme hoodie

I am typically to blogging and i really recognize your content. The article has really peaks my interest. I'm going to bookmark your website and keep checking for brand spanking new information.

Add new comment | arxic Drupal

My coder is trying to persuade me to move
to .net from PHP. I have always disliked the idea because of the costs.
But he's tryiong none the less. I've been using WordPress
on a variety of websites for about a year and am concerned about switching to another platform.
I have heard good things about blogengine.net. Is there a way I can transfer all my wordpress content
into it? Any kind of help would be really appreciated!

yeezy shoes

Thank you so much for providing individuals with an exceptionally marvellous chance to read articles and blog posts from here. It is always very excellent and as well , full of a great time for me personally and my office peers to visit your site the equivalent of 3 times weekly to learn the latest things you will have. And indeed, I am just actually pleased with your fantastic suggestions served by you. Selected 3 points on this page are certainly the best we have ever had.

yeezy boost 700

Thank you for your own hard work on this web page. My niece takes pleasure in participating in internet research and it's really easy to understand why. A number of us notice all regarding the dynamic medium you produce very important information by means of this website and therefore cause response from others about this theme so our daughter is always learning a lot of things. Take pleasure in the remaining portion of the new year. You're doing a good job.

Add new comment | arxic Drupal

Hi! Do you know if they make any plugins to help with Search Engine Optimization? I'm trying
to get my blog to rank for some targeted keywords but I'm not seeing
very good gains. If you know of any please share.

Appreciate it!

yeezy boost 350

I must show some thanks to the writer for rescuing me from this type of condition. After browsing through the the web and seeing views which are not beneficial, I assumed my entire life was done. Living without the presence of strategies to the issues you've resolved as a result of your blog post is a serious case, and the ones which may have adversely affected my career if I had not discovered the blog. Your own personal capability and kindness in maneuvering all areas was crucial. I don't know what I would have done if I had not come upon such a thing like this. I can also at this time relish my future. Thanks for your time very much for this expert and sensible guide. I won't be reluctant to suggest the sites to any individual who will need guidelines on this situation.

Add new comment | arxic Drupal

With havin so much content do you ever run into any problems of plagorism
or copyright infringement? My site has a lot of
completely unique content I've either authored myself or outsourced but it seems a lot of it is popping it up all over the
web without my authorization. Do you know any ways to help stop content from being ripped off?
I'd really appreciate it.

golden goose sneakers

My husband and i got really glad Albert managed to complete his investigations with the ideas he obtained through the site. It is now and again perplexing just to be giving freely guidelines that many men and women might have been making money from. We take into account we have got the blog owner to give thanks to because of that. The illustrations you've made, the straightforward blog navigation, the friendships you can help to create - it is mostly terrific, and it's letting our son in addition to the family reason why the situation is entertaining, which is unbelievably essential. Thank you for all the pieces!

Add new comment | arxic Drupal

Have you ever thought about creating an e-book or guest authoring
on other websites? I have a blog centered on the same topics you discuss and would love to have you share some stories/information. I know my visitors
would value your work. If you're even remotely interested, feel free to send me
an e-mail.

golden goose

I must convey my passion for your kindness supporting men who absolutely need help with this particular field. Your personal dedication to passing the solution all-around has been astonishingly insightful and have continuously permitted guys and women like me to arrive at their desired goals. This useful report indicates much to me and further more to my colleagues. Thank you; from everyone of us.

Add new comment | arxic Drupal

Your style is unique in comparison to other folks I have read stuff from.
Thank you for posting when you've got the opportunity,
Guess I'll just book mark this web site.

kobe basketball shoes

I simply desired to thank you so much yet again. I am not sure the things that I might have done in the absence of the entire tricks shared by you regarding that problem. It seemed to be the terrifying situation in my position, but being able to view a professional approach you processed the issue forced me to jump over contentment. I'm just grateful for the work and then have high hopes you realize what a powerful job that you're doing educating people with the aid of your websites. I'm certain you've never encountered all of us.

Add new comment | arxic Drupal

I have learn several just right stuff here. Certainly price bookmarking for revisiting.
I surprise how much effort you set to create the sort of excellent
informative website.

curry 6

I as well as my pals were found to be viewing the excellent information located on your web blog while instantly came up with a horrible suspicion I had not expressed respect to you for those tips. My men came warmed to learn all of them and now have in truth been taking advantage of these things. Thanks for indeed being considerably kind and then for settling on such awesome ideas most people are really needing to understand about. My personal sincere regret for not saying thanks to sooner.

Add new comment | arxic Drupal

Magnificent beat ! I wish to apprentice at the same time as you amend your website, how can i subscribe for a blog web site?
The account aided me a appropriate deal. I were tiny bit acquainted of this your broadcast provided brilliant clear idea

off white hoodie

I intended to create you one very small word to finally thank you so much as before with the remarkable advice you have contributed here. This has been remarkably open-handed with people like you to deliver without restraint just what a number of people might have supplied for an ebook to generate some bucks for their own end, precisely seeing that you might have tried it in the event you wanted. The principles as well served to be a easy way to recognize that most people have the identical eagerness similar to mine to understand a little more with regards to this matter. I think there are thousands of more pleasurable situations in the future for many who view your website.

Add new comment | arxic Drupal

You have made some good points there. I looked on the internet to learn more about the issue and found most people will go along with your views on this website.

coach outlet

I happen to be commenting to make you understand what a beneficial experience my wife's child went through visiting your blog. She figured out too many things, most notably how it is like to possess an excellent giving nature to get many others just learn several tricky subject areas. You undoubtedly surpassed visitors' expectations. Thank you for showing the good, healthy, explanatory not to mention cool guidance on that topic to Ethel.

Add new comment | arxic Drupal

I simply couldn't go away your web site prior to suggesting that I really
enjoyed the standard info a person provide to your guests?

Is going to be back ceaselessly in order to inspect new posts

vans

Thank you for your own efforts on this site. My niece really likes doing internet research and it is simple to grasp why. Many of us know all regarding the dynamic ways you deliver vital things via the web blog and inspire participation from the others about this theme then our child is in fact becoming educated a lot of things. Take advantage of the remaining portion of the new year. You're the one conducting a terrific job.

Add new comment | arxic Drupal

When someone writes an post he/she keeps the thought of a user in his/her mind that how a user can be aware of it.

So that's why this piece of writing is great. Thanks!

curry 5

I and my buddies have been reading through the excellent secrets and techniques found on your web page and then before long I got an awful suspicion I had not expressed respect to the blog owner for them. All the women are already so glad to read through all of them and have now really been taking pleasure in them. I appreciate you for really being very accommodating as well as for getting certain decent subjects most people are really needing to learn about. My very own sincere regret for not saying thanks to you earlier.

Add new comment | arxic Drupal

I loved as much as you will receive carried out right here.

The sketch is tasteful, your authored material stylish.
nonetheless, you command get bought an nervousness over that you wish be delivering the following.
unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike.

nike air max95

Needed to draft you a little remark to finally give many thanks as before with the fantastic thoughts you've shared here. It is open-handed with you to convey extensively what many people would've offered for sale as an electronic book to get some dough for themselves, most notably given that you could possibly have tried it if you decided. These techniques likewise worked to become fantastic way to know that other individuals have the identical passion like my very own to see somewhat more with reference to this problem. I'm sure there are some more fun periods ahead for many who view your site.

Add new comment | arxic Drupal

I must thank you for the efforts you've put in writing this site.
I'm hoping to see the same high-grade content from you later on as well.
In fact, your creative writing abilities has inspired me to
get my own, personal blog now ;)

nike lebron 15

I precisely wished to say thanks again. I'm not certain what I could possibly have used in the absence of the actual strategies contributed by you relating to that question. Entirely was the depressing difficulty in my view, but understanding your professional strategy you dealt with that took me to jump for joy. I am happy for your guidance and as well , wish you are aware of an amazing job you are getting into training men and women through a web site. Most likely you haven't encountered all of us.

golden goose outlet

A lot of thanks for your whole effort on this site. My mom loves managing investigations and it's really easy to understand why. My partner and i learn all about the powerful method you deliver both interesting and useful things via your website and therefore boost participation from visitors about this concept and our girl is now discovering so much. Enjoy the rest of the year. You are performing a wonderful job.

Add new comment | arxic Drupal

Hello! This is my first visit to your blog!
We are a collection of volunteers and starting a new initiative in a community
in the same niche. Your blog provided us useful
information to work on. You have done a marvellous job!

jordan 4

I must show thanks to the writer for bailing me out of this type of situation. Because of researching throughout the internet and meeting opinions that were not pleasant, I thought my life was done. Existing without the strategies to the issues you've fixed all through your main posting is a critical case, and those which may have negatively affected my career if I hadn't noticed your web site. The talents and kindness in taking care of the whole lot was precious. I'm not sure what I would've done if I had not come upon such a point like this. I'm able to at this time look ahead to my future. Thanks very much for this expert and effective guide. I will not be reluctant to recommend your web blog to any person who wants and needs direction about this problem.

Add new comment | arxic Drupal

I think this is among the most significant information for me.

And i am glad reading your article. But want to
remark on some general things, The site style is
ideal, the articles is really great : D. Good job, cheers

converse shoes

I enjoy you because of your entire labor on this site. My niece takes pleasure in getting into investigation and it's simple to grasp why. I hear all about the compelling ways you make rewarding strategies through your web site and even encourage contribution from website visitors about this situation plus our own simple princess has always been becoming educated a lot of things. Take advantage of the rest of the new year. You are conducting a superb job.

Add new comment | arxic Drupal

The other day, while I was at work, my cousin stole my iphone
and tested to see if it can survive a twenty five foot drop, just so she can be
a youtube sensation. My apple ipad is now destroyed and she has 83 views.
I know this is totally off topic but I had to share
it with someone!

michael kors outlet

I wanted to draft you this very small remark to finally thank you so much again just for the pleasant techniques you have provided in this article. This has been really incredibly open-handed with you to present extensively what exactly a lot of people might have offered for sale for an e-book to generate some money on their own, specifically now that you could have done it if you wanted. These thoughts additionally worked to provide a easy way to understand that other people have the same interest similar to mine to find out very much more around this condition. I'm sure there are lots of more fun opportunities in the future for people who check out your site.

Pages

Add new comment