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

traje de ba帽os para ni帽os

bolsas at茅 30 reais lesao no ligamento <a href="http://www.haberdeprem.com/bolsinha_de_cintura/moda-de-saia-2016">moda de saia 2016</a> chuteira dalponte campo gray and white comforter sets <a href="http://www.applepoison.com/sofa_y_cia_fundas/privath%c3%a4user-zu-vermie...盲user zu vermieten</a> nissan rogue all weather mats <a href="http://www.sp-racking.com/site_da_loja_nike/j%c3%a1-come%c3%a7ou-o-black...谩 come莽ou o black friday</a> sneakers ni帽a <a href="http://www.gracebomer.com/s谩banas_de_seda/comprar-air-force-baratas">comprar air force baratas</a>
traje de ba帽os para ni帽os http://www.ratawatanews.com/air_force_lunarlon/traje-de-ba%c3%b1os-para-...

n68lqrv r86iec

Funda silicona TPU suave trasera para iPhone 11 Pro

<a href="http://www.sinchiwarmiamazonlodge.com/arcase-aligoods/卮禺氐賷丞-丌賷賮賵賳-xs-賲丕賰爻-睾胤丕亍-賴丕鬲賮-賯賱丕亘-賲賳-丕賱噩賱丿-丨賯賷亘丞-賱賴丕鬲賮-兀賷-賮賵賳-XS-11-亘乇賵-賲丕賰爻-XR-賱爻丕賲爻賵賳噩-睾丕賱丕賰爻賷-S7-丨丕賮丞-賮鬲丨丞-睾胤丕亍-丕賱賴丕鬲賮">卮禺氐賷丞 丌賷賮賵賳 xs 賲丕賰爻 睾胤丕亍 賴丕鬲賮 賯賱丕亘 賲賳 丕賱噩賱丿 丨賯賷亘丞 賱賴丕鬲賮 兀賷 賮賵賳 XS 11 亘乇賵 賲丕賰爻 XR 賱爻丕賲爻賵賳噩 睾丕賱丕賰爻賷 S7 丨丕賮丞 賮鬲丨丞 睾胤丕亍 丕賱賴丕鬲賮</a> <a href="http://www.wikiparlemen.com/case-aligoods/Funda-de-cuero-con-tapa-para-S... para samsung j5 prime</a> <a href="http://www.wikiparlemen.com/case-aligoods/Funda-para-telfono-personaliza... tablet huawei t3 10</a> <a href="http://www.ajans414.com/arcase-aligoods/卮禺氐賷丞-兀賳丕-噩乇丕亘-賴丕鬲賮-2020-賲賵囟丞-賲禺氐氐-賲胤亘賵毓丞-氐賵乇-丕賱賴丕鬲賮-丨賯賷亘丞-賱賴丕鬲賮-兀賷-賮賵賳-賲丕賰爻-X-XS-XR-6-6s-7-8-Plus-卮毓丕乇">卮禺氐賷丞 兀賳丕 噩乇丕亘 賴丕鬲賮 2020 賲賵囟丞 賲禺氐氐 賲胤亘賵毓丞 氐賵乇 丕賱賴丕鬲賮 丨賯賷亘丞 賱賴丕鬲賮 兀賷 賮賵賳 賲丕賰爻 X XS XR 6 6s 7 8 Plus 卮毓丕乇</a>
Funda silicona TPU suave trasera para iPhone 11 Pro https://es.aliexpress.com/item/4000644653291.html

casquillo de seguridad para zapatos

yeezy 350 amarillas <a href="http://www.gracebomer.com/nancy_antigua/tenis-reebok-colores">tenis reebok colores</a> vestido de noche para embarazadas manual cycling machine <a href="http://www.applepoison.com/protege_canap茅_angle/weathertech-door-guards">weathertech door guards</a> colete masculino marisa loja do cruzeiro brasilia <a href="http://www.2amoda.com/moleca_casual/saco-para-boxe">saco para boxe</a> tv android 40 sabanas 1 80 x 1 90 juegos para ni帽os de 3 a帽os <a href="http://www.ratawatanews.com/chanclas_fila_negras/vestidos-de-graduacion-... de graduacion largos azul</a> reebok suela de liga
casquillo de seguridad para zapatos http://www.4unitedforcenews.com/maurice_lacroix_shop/casquillo-de-seguri...

arc teryx mens zeta lt jacket

MzI VR eVgfxwu

webcam girls <a href=https://camgirls1.com>camgirls1.com</a> girls on live cam.
hot cam girls <a href=https://hotcamgirls1.com>live cam girls </a> girls web cam videos.
free cam to cam sex <a href=https://bestonlinesexcams1.com>bestonlinesexcams1.com</a> drunk sex caught on cam.
sexy cam girls <a href=https://bestonlinesexwebcams.com>bestonlinesexwebcams.com</a> sex cam reviews.
top cam sites <a href=https://adultfreewebcamsites.com>top 10 webcam sites </a> best chat cam sites.
porn cam sites <a href=https://adultcamsites1.com>cam to cam site </a> webcam sites for couples.

WYs Se qNAwBhg

model porn <a href=https://camgirls1.com>camgirls1.com</a> free camgirl.
webcam girls <a href=https://hotcamgirls1.com>hotcamgirls1.com</a> romanian girls names.
sex cam sites <a href=https://bestonlinesexcams1.com>rabbit cam sex </a> live free webcam sex.
rabbit cam sex <a href=https://bestonlinesexwebcams.com>asian sex cam </a> real hidden cam sex.
couple cam sites <a href=https://adultfreewebcamsites.com>popular cam site </a> asian webcam sites.
webcam sites <a href=https://adultcamsites1.com>cam girl sites </a> popular webcam sites.

CRd GZ LWnWIbr

young cam girls <a href=https://camgirls1.com>camgirls1.com</a> black girls live cam.
chaturbate model <a href=https://hotcamgirls1.com>hotcamgirls1</a> girl webcam video.
sexcams <a href=https://bestonlinesexcams1.com>bestonlinesexcams1.com</a> sex cam to cam.
live sex webcam <a href=https://bestonlinesexwebcams.com>bestonlinesexwebcams</a> mobile cam sex.
best cam to cam sites <a href=https://adultfreewebcamsites.com>safe cam sites </a> adult live cam sites.
asian cam site <a href=https://adultcamsites1.com>most popular webcam sites </a> top 10 cam sites.

scarpin verniz preto

<a href="http://www.zielusiana.com/visierhelm/abendkleider-ab-30-euro">abendkleider ab 30 euro</a> <a href="http://www.diariologia.com/gal谩ctica/imagem-da-camisa-do-vasco">imagem da camisa do vasco</a> <a href="http://www.ilkelikocaeli.com/amortiguacion/articulos-para-beisbol-gucci"... para beisbol gucci</a> <a href="http://www.ideesangati.com/sheboygan_inkerman/%d7%94%d7%a2%d7%95%d7%91%d...讛注讜讘讚 拽讬讘诇 砖讻专 讻讜诇诇 讜讻注转 转讜讘注 砖注讜转 谞讜住驻讜转 诇诪注住讬拽 拽诪讛 讟注谞转</a>
scarpin verniz preto http://www.conceicaoverdade.com/entraram/scarpin-verniz-preto

paraguas antiviento decathlon

Pages

Add new comment