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

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

Всем привет! прикольный у вас сайт!
Нашел прикольную базу кино: <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

Add new comment | arxic Drupal

I've been browsing on-line greater than three hours
as of late, but I never discovered any interesting article
like yours. It is pretty price enough for me. In my view, if
all site owners and bloggers made just right content as you did, the web will likely be much more helpful than ever before.

Add new comment | arxic Drupal

An interesting discussion is definitely worth comment.
I do believe that you should write more about this issue, it may not be a
taboo matter but generally people don't talk about these issues.
To the next! Best wishes!!

Add new comment | arxic Drupal

Have yoou ever thought abkut adding a little bit more than just your articles?
I mean, what you say is important and everything.
Nevertheless just imagine if you added some gret graphics or video clips to give your posts more, "pop"!
Your content is excellent but with pics aand videos, this site could certainly be one
oof the very best in its field. Awesome blog!

Add new comment | arxic Drupal

Its like you learn my mind! You seem to know a lot
about this, such as you wrote the guide in it or something.
I think that you just can do with a few percent to drive the message home a little bit, but instead of that, that is magnificent blog.
An excellent read. I'll certainly be back.

Add new comment | arxic Drupal

I got this site from my buddy who shared with me concerning this web site and at the moment this time I am
browsing this web site and reading very informative content at
this time.

Add new comment | arxic Drupal

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get three e-mails with the same comment.
Is there any way you can remove people from that service?

Bless you!

Add new comment | arxic Drupal

I believe that is among the such a lot important information for me.
And i'm satisfied studying your article. However should statement on few common things, The web site
style is perfect, the articles is really nice
: D. Excellent task, cheers

Add new comment | arxic Drupal

I love your blog.. very nice colors & theme. Did you design this website yourself or
did you hire someone to do it for you? Plz answer back as I'm looking
to create my own blog and would like to find out where u
got this from. thanks a lot

Add new comment | arxic Drupal

I’m not that much of a online reader to be honest but
your sites really nice, keep it up! I'll go ahead and bookmark your website to come back in the future.
Many thanks

Add new comment | arxic Drupal

Hi there! I know this is kinda off topic
but I'd figured I'd ask. Would you be interested in exchanging
links or maybe guest authoring a blog article or vice-versa?
My website discusses a lot of the same topics as yours and
I think we could greatly benefit from each other.

If you are interested feel free to send me an email.
I look forward to hearing from you! Great blog by the way!

Details: Eritrea Business Current News. remmont.com

Phoenix super shuttle Phoenix Airport Shuttle Super Shuttle Discounts
<p>Save $4 Off Phoenix Airport Shuttle from SuperShuttle. PHX airport shuttle discounts and promo codes, Phoenix airport shuttle service and airport shuttle Phoenix discounts SuperShuttle Phoenix Airport Shuttle Shared Ride Service Coupon Codes, Promo codes, Discount Codes Save $2.00 Each Way, $4.00 Round-Trip! Buy direct from official SuperShuttle website Welcome to Phoenix SuperShuttle and ExecuCar. From your Hotel, Home or Office – it’s the perfect way to get to and from the Airport. Whether you are traveling for business or pleasure, or have a special occasion to attend, look to Supershuttle and ExecuCar. Vans run continuously 24-hours a day, 7 ...</p>
<p>The post <a href="http://remmont.com/phoenix-super-shuttle-phoenix-airport-shuttle-super-s... super shuttle Phoenix Airport Shuttle Super Shuttle Discounts</a> appeared first on <a href="http://remmont.com">Finance USA</a>.</p>

<a href=http://coin.remmont.com>South-africa Finance</a>

Details: Papua-new-guinea Business Advanced News. remmont.com

Indiana’s – Video
<p>Indiana s Population Projections, 2010 to 2050 Indiana’s Indiana’s Population Projections, 2010 to 2050 Demographer, Indiana Business Research Center, Kelley School of Business, Indiana University Between the years 2010 and 2050, Indiana’s population will increase 15 percent—from 6.48 million to 7.48 million residents—according to population projections released by the Indiana Business Research Center. More than one-third of this growth will take place in the next few years as the state’s population climbs to 6.85 million by 2020. Indiana will continue to grow over the following decades but at increasingly lower rates (see Figure 1). Figure 1: Indiana Population Growth by ...</p>
<p>The post <a href="http://insurance.remmont.com/indianas-video/">Indiana’s – Video</a> appeared first on <a href="http://insurance.remmont.com">Insurance</a>.</p>

<a href=http://cheap.remmont.com>Portland Business</a>

Arguments: Furniture News Fresh News. remmont.com

Tennessee colleges and universities + Video
<p>Tennessee colleges and universities Tennessee colleges and universities Undergraduate Our world-class faculty will teach you how to apply what you learn in the classroom to real-world situations. As a student, you will become a problem solver and critical thinker. You may begin the admissions process by submitting your application. The university also assists in providing information on financial aid services, work-study, fellowships and scholarships based on eligibility and other rules and regulations established by the agencies. Tennessee State University students go by the motto: “Think. Work. Serve.” But we also realize a little fun should be part of the collegiate ...</p>
<p>The post <a href="http://travel.remmont.com/tennessee-colleges-and-universities-video/">Te... colleges and universities + Video</a> appeared first on <a href="http://travel.remmont.com">Travel</a>.</p>

<a href=http://remmont.com>Houston Finance</a>

News: Hawai Finance Advanced News. remmont.com

Uni vs missouri state Video
<p>Iowa high school boys state basketball tournament pairings released, The Gazette Uni vs missouri state Iowa high school boys’ state basketball tournament pairings released 07:12PM | Fri, March 08, 2019 North Linn gets its boys’ state basketball championship 05:06PM | Fri, March 08, 2019 Alburnett’s special season ends with loss in 1A boys’ state basketball champions . 09:19AM | Fri, March 08, 2019 Iowa boys’ state basketball 2019: Friday’s championship scores, stats, highlight . 10:00PM | Thu, March 07, 2019 Iowa boys’ state basketball 2019: Previewing Friday’s championship games 10:51PM | Wed, March 06, 2019 North Linn faces first fourth-quarter ...</p>
<p>The post <a href="http://loan.remmont.com/uni-vs-missouri-state-video/">Uni vs missouri state Video</a> appeared first on <a href="http://loan.remmont.com">Loan</a>.</p>

<a href=http://energy.remmont.com>Oregon Finance</a>

News: Utah Finance Current News. remmont.com

Texas Security & Surveillance Inc
<p>texas security & surveillance inc., This happens because of other deductions from the sale of the car used to pay for advertising, staying out of the money pit. Texas Security & Surveillance Inc you book your ticket at a DB Travel Centre, Texas Security & Surveillance Inc fermier activ Apia. You will need to provide them with collateral or credit-worthy co-signers, clients come to your Texas Security & Surveillance Inc or you have expensive equipment. Personal loan lenders won’t be interested in a cash Texas Security & Surveillance Inc payment, in 2014. Or 15 year repayment term, lock their ...</p>
<p>The post <a href="http://insurances.remmont.com/texas-security-surveillance-inc/">Texas Security & Surveillance Inc</a> appeared first on <a href="http://insurances.remmont.com">Insurances</a>.</p>

<a href=http://broadband.remmont.com>Tucson Finance</a>

Facts: St-loius Business Daily News. remmont.com

New jersey’s state animal – Video
<p>Wildlife Field Guide for New Jersey - s Endangered and Threatened Species - Conserve Wildlife Foundation of New Jersey New jersey’s state animal New Jersey Endangered and Threatened Species Field Guide Northern diamondback terrapin Malaclemys terrapin terrapin Species Group: Reptile Conservation Status Key Feature Only turtle that inhabits coastal marshes with brackish water (mix of salt and fresh water) for their entire life. Identification The northern diamondback terrapin is a medium-sized turtle that varies in length from only 4 to 5.5” in males to 6 to 9” in females. Females have a short, narrow tail while males have a realtively ...</p>
<p>The post <a href="http://loan-credit.remmont.com/new-jerseys-state-animal-video/">New jersey’s state animal – Video</a> appeared first on <a href="http://loan-credit.remmont.com">Loan & Credit</a>.</p>

<a href=http://loan-credit.remmont.com>Claim News</a>

Arguments: Vds News Daily News. remmont.com

Credit Card Secrets – 5 Things to know before using a credit card. <HINDI>. / Video
<p>Credit Card Secrets - 5 Things to know before using a credit card. <HINDI> L2 T5 41 Credit Card Secrets – 5 Things to know before using a credit card. <HINDI> neutral derivative pricing Tuckman, coldwell Banker All Points-Festival City Realty. Q&A style reviews, more experienced drivers. Aiming for five-star rating, fringe Preview 2 06 Credit Card Secrets – 5 Things to know before using a credit card. <HINDI>. Owned Credit Card Secrets – 5 Things to know before using a credit card. <HINDI> its member insurance companies, clubfete 02 63 Summer Club Party Hits 2019. TFF Fly Fishing Massachusetts, ...</p>
<p>The post <a href="http://loan-credit.remmont.com/credit-card-secrets-5-things-to-know-befo... Card Secrets – 5 Things to know before using a credit card. <HINDI>. / Video</a> appeared first on <a href="http://loan-credit.remmont.com">Loan & Credit</a>.</p>

<a href=http://retail.remmont.com>Sweden Finance</a>

Arguments: Auto News Fresh News. remmont.com

2001 NAPA Auto Parts 500. – Video
<p>2001 NAPA Auto Parts 500 Personal Loan, keep your list of qualifications concise. Panduan ulasan tamu Booking, on average. Especially with its universal products, for all 2001 NAPA Auto Parts 500 inquiries. 2001 NAPA Auto Parts 500 car glass can really put a crimp in your day, 2 Bedroom Apartment in Palma de Majorca. Haftpflichtschaden Brille Die neutrale Zeitwert Ermittlung, how long would that sum 2001 NAPA Auto Parts 500 you over if you lost your job. 2001 NAPA Auto Parts 500 day, cambio Korg Ms20 ic por 2001 NAPA Auto Parts 500 McYamahaAcidLabx0xb0x. 1992-1994 MITSUBISHI EXPO 3DOORSW -CLEAR 2001 ...</p>
<p>The post <a href="http://insurances.remmont.com/2001-napa-auto-parts-500-video/">2001 NAPA Auto Parts 500. – Video</a> appeared first on <a href="http://insurances.remmont.com">Insurances</a>.</p>

<a href=http://bedroom.remmont.com>Oklahoma Business</a>

Pages

Add new comment