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

supreme shirt

I have to show my appreciation to the writer for bailing me out of this particular crisis. Right after looking out throughout the world-wide-web and coming across ideas which are not helpful, I was thinking my life was gone. Being alive without the approaches to the difficulties you've solved as a result of the posting is a critical case, as well as those which may have adversely affected my career if I hadn't encountered the blog. Your own personal talents and kindness in dealing with all the stuff was helpful. I am not sure what I would have done if I had not discovered such a point like this. It's possible to at this time relish my future. Thanks so much for your reliable and effective help. I won't hesitate to refer the sites to any individual who needs guidance about this situation.

Add new comment | arxic Drupal

Wonderful beat ! I would like to apprentice while you amend your
website, how can i subscribe for a blog web site? The account aided me
a acceptable deal. I had been tiny bit acquainted of
this your broadcast offered bright clear concept

Add new comment | arxic Drupal

Oh my goodness! Amazing article dude! Thanks, However I am
experiencing problems with your RSS. I don't know the reason why I can't join it.

Is there anyone else getting the same RSS problems? Anybody
who knows the answer can you kindly respond? Thanx!!

balenciaga shoes

Hey! I simply want to give an enormous thumbs up for the great info you've gotten right here on this post. I will likely be coming back to your weblog for extra soon.

yeezy boost

An impressive share, I just given this onto a colleague who was doing a little bit evaluation on this. And he actually bought me breakfast because I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love studying extra on this topic. If possible, as you turn out to be experience, would you thoughts updating your weblog with extra details? It's extremely helpful for me. Big thumb up for this weblog put up!

nike air max 97

After research a couple of of the blog posts on your website now, and I really like your approach of blogging. I bookmarked it to my bookmark web site record and will probably be checking again soon. Pls try my web page as nicely and let me know what you think.

fitflops sale clearance

There are some interesting cut-off dates in this article but I don抰 know if I see all of them middle to heart. There's some validity but I'll take hold opinion till I look into it further. Good article , thanks and we want extra! Added to FeedBurner as nicely

mbt shoes

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

golden goose

I just wanted to make a quick note to appreciate you for these great information you are sharing here. My rather long internet look up has at the end been compensated with reputable concept to write about with my contacts. I would say that we visitors actually are very much lucky to live in a fantastic community with so many marvellous professionals with interesting things. I feel very grateful to have discovered your website and look forward to so many more enjoyable moments reading here. Thank you once again for a lot of things.

nike react

Thanks a lot for providing individuals with such a splendid chance to read critical reviews from this web site. It is usually very terrific and as well , jam-packed with a good time for me and my office fellow workers to search your site at the very least 3 times in a week to learn the new things you will have. And lastly, we are at all times contented with your attractive strategies you give. Certain 2 facts in this post are particularly the very best we have all ever had.

coach handbags

Needed to create you one very little remark in order to say thanks again on the wonderful strategies you have contributed here. It's really remarkably open-handed of you to allow publicly just what a lot of people would've made available as an e-book to help make some bucks on their own, certainly seeing that you might have done it if you wanted. Those tips in addition acted to become great way to know that other people online have similar interest just as my personal own to understand a good deal more with reference to this condition. I am certain there are thousands of more pleasurable times in the future for individuals that read through your blog post.

adidas stan smith men

I am only writing to let you know of the wonderful experience our daughter went through browsing your site. She learned a wide variety of pieces, including how it is like to possess an excellent helping nature to have a number of people clearly know just exactly a variety of complex topics. You really exceeded people's desires. Many thanks for delivering those effective, dependable, revealing and unique tips on your topic to Kate.

adidas nmd

I wish to express my appreciation to this writer just for rescuing me from this type of issue. As a result of scouting through the the net and coming across things which are not beneficial, I was thinking my life was gone. Existing minus the strategies to the difficulties you've solved through your main short article is a serious case, and the ones that would have adversely affected my career if I hadn't discovered your blog. The ability and kindness in playing with all things was very useful. I don't know what I would've done if I hadn't discovered such a point like this. I can also now look ahead to my future. Thank you very much for your professional and amazing help. I will not hesitate to endorse your web sites to anyone who will need counselling about this subject.

off white jordan 1

I simply needed to thank you so much all over again. I'm not certain the things I could possibly have taken care of in the absence of the strategies shown by you concerning such a problem. It was actually the hard case in my position, nevertheless being able to view this expert way you resolved that made me to cry with gladness. I am happy for this help and believe you know what an amazing job you are accomplishing training some other people with the aid of a site. Probably you've never come across any of us.

chrome hearts store

I in addition to my guys have been following the nice suggestions located on your web site then before long came up with a terrible feeling I never expressed respect to the blog owner for those techniques. These boys ended up for this reason very interested to read through all of them and have now in truth been making the most of those things. We appreciate you indeed being really accommodating and then for utilizing this kind of incredibly good areas millions of individuals are really wanting to be informed on. Our own sincere apologies for not expressing appreciation to you sooner.

louboutin shoes

I simply had to thank you so much once more. I'm not certain the things I would have gone through in the absence of these points shown by you concerning that concern. Previously it was the fearsome condition for me, but looking at a specialised style you handled the issue took me to jump with joy. Extremely happy for this guidance and then trust you are aware of a powerful job you're providing teaching people today with the aid of your web page. I know that you haven't got to know all of us.

golden goose

Thanks for each of your labor on this blog. My aunt really likes engaging in investigation and it's easy to see why. My spouse and i hear all of the lively way you make vital ideas by means of the web blog and even inspire contribution from others on this article plus our favorite princess is really studying a great deal. Take pleasure in the rest of the year. You are conducting a great job.

birkin bag

I wanted to put you one little note in order to say thank you as before for those superb thoughts you've discussed here. This is unbelievably open-handed with you to give openly what a number of people could have distributed as an e-book to generate some cash on their own, specifically since you might well have done it in the event you wanted. Those solutions also worked to provide a easy way to recognize that the rest have the identical keenness like my very own to know very much more when it comes to this problem. I know there are many more fun periods in the future for people who scan through your website.

supreme clothing

I want to express some thanks to the writer just for rescuing me from this predicament. Because of looking out throughout the world wide web and meeting advice which were not pleasant, I believed my entire life was well over. Being alive without the presence of strategies to the problems you have sorted out by means of the short post is a crucial case, and the kind which could have badly affected my career if I had not encountered your web blog. Your own natural talent and kindness in dealing with all things was very helpful. I'm not sure what I would've done if I had not encountered such a thing like this. It's possible to at this moment look forward to my future. Thanks a lot so much for the skilled and amazing guide. I won't think twice to propose the sites to any person who needs and wants recommendations on this problem.

смотреть в хорошем качестве hd 720 фантастику

Приветствую всех! интересный у вас сайт!
Нашел топ базу кино: <a href=http://inspacefilm.ru/>мультфильмы 2018 смотреть бесплатно в хорошем полностью</a>
Здесь: <a href=http://inspacefilm.ru/semeynyy/>семейный фильм онлайн бесплатно в хорошем качестве</a> фильмы 2018 семейные список 2019
Тут: вечность сериал смотреть онлайн бесплатно в хорошем http://inspacefilm.ru/serialy/ список 2018
Тут: лучшие триллеры 2018 смотреть онлайн бесплатно http://inspacefilm.ru/triller/ список 2018
Тут: http://inspacefilm.ru/10210-gildiya-prodyuserov-ssha-predstavila-svoih-n... <b> Гильдия продюсеров США представила своих номинантов (фильмы) </b>
Тут: http://inspacefilm.ru/13205-suprugi-morgan-v-begah-did-you-hear-about-th...

Add new comment | arxic Drupal

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

Add new comment | arxic Drupal

Thanks for your marvelous posting! I certainly enjoyed reading it, you happen to be a great author.I will be
sure to bookmark your blog and will often come back in the foreseeable future.
I want to encourage continue your great job, have a nice holiday weekend!

Add new comment | arxic Drupal

Does your website have a contact page? I'm having a tough time locating it but, I'd
like to shoot you an email. I've got some ideas for your blog
you might be interested in hearing. Either way, great website and I
look forward to seeing it improve over time.

Add new comment | arxic Drupal

We stumbled over here different web page and thought I might as
well check things out. I like what I see so now i'm following you.
Look forward to exploring your web page for a second time.

Add new comment | arxic Drupal

You actually make it seem so easy with your presentation but I find this matter to be actually something which I
think I would never understand. It seems too complicated and very broad for me.
I am looking forward for your next post, I'll try to get
the hang of it!

Add new comment | arxic Drupal

Woah! I'm really digging the template/theme of this website.

It's simple, yet effective. A lot of times
it's hard to get that "perfect balance" between superb usability and visual appeal.
I must say you have done a fantastic job with this.
Also, the blog loads super fast for me on Chrome.

Outstanding Blog!

Add new comment | arxic Drupal

Excellent beat ! I would like to apprentice while you amend
your website, how could i subscribe for a blog web site?
The account helped me a acceptable deal. I had been tiny bit acquainted of this
your broadcast provided bright clear concept

как домашними средствами усилить потенцию

Привет всем участникам форума! прикольный у вас сайт!
Нашел интересную инфу: <b> как быстро похудеть за день </b> <a href=http://sportmanlife.ru/>http://sportmanlife.ru/</a>
Здесь: как быстро накачать нижний пресс http://sportmanlife.ru/kak-nakachat-press/
Тут: <a href=http://sportmanlife.ru/52-rasputnica-rasputnica-naturalnye-innovacionnye...капли для возбуждения женщин в аптеках название</a> сколько стоят капли распутница
Тут: <a href=http://sportmanlife.ru/46-krem-titan-gel-uvelichenie-chlena-i-usilenie-p...увеличение члена в домашних условиях</a> titan gel сайт

how to make profit

Hello, tired of sitting with no money?
I was just a poor student, and now i make 1100$ - 1400$ every day here: http://9binaryoptions.net/uploads/reviews/passive-business-ideas.htm - make real money online
It works! Checked. Good luck to all!

This online work from home is available in all countries! These articles will help you:
<a href=http://9binaryoptions.net/uploads/reviews/best-way-to-earn-money-from-ho... best way to earn money from home </a>
<b> Бинарные опционы мнение </b> <a href=http://9binaryoptions.net/ru> Бинарные опционы мнение </a>
Start Now!

Add new comment | arxic Drupal

I'm not sure exactly why but this blog is loading very slow for me.

Is anyone else having this problem or is it a issue on my end?
I'll check back later and see if the problem still exists.

смотреть кино лучший триллер

Всем привет! прикольный у вас сайт!
Нашел прикольную базу кино: <a href=http://kinoserialtv.net/>лучшие русские сериалы детективы смотреть онлайн</a>
Тут: фантастика 2018 смотреть бесплатно в хорошем качестве http://kinoserialtv.net/fantastika/ рейтинг 2018
Здесь: <a href=http://kinoserialtv.net/komediya/>лучшие новые комедии смотреть</a> бесплатные лучшие комедии 2019 года рейтинг 2018
Тут: <a href=http://kinoserialtv.net/melodrama/>смотреть лучшие русские мелодрамы новинки</a> фильмы 2019 смотреть хорошем бесплатно онлайн мелодрамы рейтинг 2018
Здесь: http://kinoserialtv.net/2995-moy-mir-benim-dunyam-2013.html <b> Смотреть Мой мир / Benim Dunyam (2013) онлайн бесплатно </b>
Тут: http://kinoserialtv.net/249-kolin-ford-o-seriale-pod-kupolom.html

Pages

Add new comment