This is an old revision of the document!


How to use CloudLinux Node.js Selector with LSWS

As JavaScript became one of the most popular programming languages, more and more customers demand Node.js hosting. CloudLinux Node.js Selector was introduced to facilitate the performance and functionality related to Node.js. LSWS added CloudLinux Node.js Selector support starting from 5.3RC1 release.

Node.js Selector from Cloudlinux is supported by Litespeed Web server out of the box. You will need to follow the instructions in the CloudLinux Node.js selector. You can refer to CloudLinux official documentation.

You can create file with the name index.js and content:

var http = require('http');
var server = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    var message = 'It works!\n',
        version = 'NodeJS ' + process.versions.node + '\n',
        response = [message, version].join('\n');
    res.end(response);
});
server.listen();

Point your browser to http://domain.com/index.js

The result is:

Note that any port specifications in the listen function are ignored. The server is processed by the Node.js function of Litespeed automatically.

If you see only the code of the file like this:

you need to check from cPanel → NoteJS selector if your application is started. You can start it from there or restart it. If you still see only the source code make sure that your server is running Litespeed web server version 5.3 or higher.

You can also check to verify that the 'Litespeed Node.js Service' is running. From a command prompt enter: ``` ps -ef|grep Node ``` and one of the displayed running processes should be `Litespeed Node.js Service

  • Admin
  • Last modified: 2018/05/24 14:53
  • by Robert Perper