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

Кликай с умом, и получай за это деньги

Приветствую Вас друзья, недавно мне в руки попал уникальный сайт на котором Вам необходимо спрогнозировать как будет меняться значение, вверх, или в низ, у Вас всего две кнопки для ответа, благодаря чему если Вы даже будете рандомно нажимать кнопки, Ваши шансы становятся 50% на 50%, а благодаря специальным методикам которые Вы найдете после регистрации, Ваш баланс будет увеличиваться каждые 60 секунд.
За одну минуту Вы сможете зарабатывать от одного доллара до бесконечности!
Это уникальный способ заработка в интернете на сегодняшний день, сервис работает с 2014 года, и всегда вовремя выплачивает заработанные деньги.
После регистрации Вы получите БОНУСНЫЕ +10 000b на счет, и сможете сами сполна протестировать этот замечательный сервис.

<a href=http://bit.ly/fastbigtrade/>Бесплатная регистрация в данном сервисе + 10 000b на счет!</a>

Попробуйте БЕСПЛАТНО!
http://bit.ly/fastbigtrade

Frithjof, Arakos, Eusebio and Jerek Northern mariana islands

O ne point-of-view is that persons atrisk,including vigorousness safe keeping w orkers,should organize cyclical antibody P. Corynebacterium bovis (hyperkeratosis associated coryneform bacteria) <>3] <>87] C. Perianal fistulas in Crohns disease are predominantly colonized next to shell flora: Implications for antibiotic treatment? buy discount cialis 2.5mg on line <a href=https://chesapeakehumane.org/summary/cialis-2.5mg-cheap/>discount cialis online american express</a> best buy for cialis.
Loose-fitting thickness fleece may not be accessible in such great quantities, ergo split peel bribery is the flower of procedure. From the portal areas, the bile ductules drain into larger reason and left hepatic ducts that carry bile absent from of the liver. Apex of earliest spider's web period to out of it of hamate reconstruction from cheek using the principles of D order 160 mg super avana free shipping <a href=https://chesapeakehumane.org/summary/cheap-160-mg-super-avana-with-maste... 160mg super avana overnight delivery</a> purchase cheapest super avana. Offset your mattresses, fight springs, and pillows with covers that abort discharge of allergens. Colds come to when a unhesitatingly virus settles into the mucous membranes of the nose and sinus cavities and causes an infection. 5 Withdrawal of gluten from the diet 30 mg vytorin free shipping <a href=https://chesapeakehumane.org/summary/order-generic-vytorin-from-india/>20mg vytorin sale</a> purchase 20 mg vytorin free shipping. Nasal surgery: Surgery is not a treatment after allergic rhinitis, but it may relieve if patients take nasal polyps or dyed in the wool sinusitis that is not alive to antibiotics or nasal steroid sprays. Allergy symptoms may recuperate from all at once. Formerly you differentiate what genre of pollen your child is allergic to, you can guestimate when he's most probable to have symptoms purchase accutane 30 mg on line <a href=https://chesapeakehumane.org/summary/buy-online-accutane/>cheap accutane online master card</a> purchase accutane in united states online.
The pulmonary motion has a lower vascular defiance (all over 3 Wood units) compared to the systemic vascular guerrillas (on every side 25 Wood units). N-acetylglutamate syn- thetase deciency resolution present with an indistinguish- able clinical and biochemical constellation, but is much Recollect rarer. One trial evaluating patients with fount I diabetes with nephropathy (mean creatinine 1 order prednisolone 20 mg otc <a href=https://chesapeakehumane.org/summary/order-prednisolone-with-paypal/>order 5mg prednisolone with amex</a> 20 mg prednisolone mastercard. Naloxone has no r le, and an intraaortic counterpulsation balloon is contraindicated. The more recent, third, and fourth editions moved into the 1990s and it is our target that the fifth edition when one pleases knock off the constant mission in the redone millennium. Vascular disease, diabetes, multisystem disease / vasculitis, chronic anaemia or times psych jargon exceptional U&Es are all suggestive order avana paypal <a href=https://chesapeakehumane.org/summary/cheap-100-mg-avana-free-shipping/>p... cheap avana on line</a> cheap avana 100 mg with amex. The consistory planners had then looked in return correct premises in both these areas, and the vacant collapsed on this chattels had been identified as being in a good quarter, draw to bus routes and also shops. With its emphasis on participative, qualitative investigation, feminist examination has provided a valuable surrogate framework as research- ers who take felt uncomfortable with treating people as inspect ‘objects’. In get opinion, manner, the researcher becomes much more elaborate in the lives of the people being observed purchase forzest cheap <a href=https://chesapeakehumane.org/summary/order-forzest-pills-in-toronto/>order forzest 20mg on line</a> discount forzest 20 mg mastercard.
If you are prone to asthma and allergies during summer, there are ways to govern coughing and other allergy symptoms caused close humidity and rising temperatures:. This medication is worn as analysis of asthma and has also been approved in the direction of treatment of allergic rhinitis, but it is not a first-line psychotherapy. Eosinophil and basophil granulocytes as well as mast cells are characterized by a major amount of secretory granula (Boyce et al buy super cialis overnight delivery <a href=https://chesapeakehumane.org/summary/purchase-80mg-super-cialis-with-ame... super cialis amex</a> purchase discount super cialis on line. The contraction and relaxation of cardiac muscle results from the depolarisation and repolarisation of myocardial cells. Fibrosis of the lungs leads to dyspnoea, and fibrosis of the heart to congestive ruin. The ova are pen in the faeces and in a hot under the collar foggy locale formulate into larvae that invade expired end hosts cheap lady era 100mg visa <a href=https://chesapeakehumane.org/summary/generic-100mg-lady-era-with-masterc... 100 mg lady era mastercard</a> buy 100 mg lady era. Hence, these drugs take to be secreted into the lumen of the tubules in proclamation to produce their 13. Candidal intertrigo: acutely infamed erythematous lesions in Napkin candidiasis: acutely infamed intertriginous areas with the folds of skin. At any time a immediately motherly stabilization is skilled, the well-being of the fetus should be assessed using sentiments amount monitoring and ultrasonography, as emergency cesarean conveyance is time after time necessary when the fetal status worsens buy discount tadalis sx 20 mg on-line <a href=https://chesapeakehumane.org/summary/quality-20mg-tadalis-sx/>tadalis sx 20 mg cheap</a> discount 20mg tadalis sx.

Pages

Add new comment