- Your cart is currently empty.
Creating Your First Node.js App in cPanel
We also now offer Node.js hosting at NEOSERV. This is primarily aimed at web developers who need a stable environment for developing and running Node.js applications. Hosting with Node.js support in cPanel includes the Green, Blue and Red packages, plus Reseller hosting packages from R1 to R5 and all TURBO hosting packages.
In today’s post, we will focus on developing a very simple Node.js application. Most likely, this will be your first application that you will build in this open source system. Before we dive a bit deeper into the development of the application itself, let’s take a look at what the Node.js module installed in the cPanel control panel has to offer.
Creating a Node.js application in cPanel
If you’ve ordered any of the hosting packages listed above from us, you’ll also find the Setup Node.js App icon in the cPanel dashboard, located in the SOFTWARE section.
The Setup Node.js App feature allows you to create applications and select a specific version of Node.js to run them. Currently supported versions are 6.x, 8.x, 9.x, 10.x, 11.x, 12.x, 14.x, 16.x, 18.x, 19.x and 20.x. If you click on the above icon, you will be presented with a friendly user interface that is completely easy to use.
First you will see a list of Node.js applications, which in your case will be empty. To create a new application, click on the blue CREATE APPLICATION button.
Here you will enter the basic settings of the app:
- Node.js version – select the desired version of the Node.js environment;
- Application mode – select development or production mode;
- Application root – specify the base or root directory of your application;
- Application URL – specify the link to your application;
- Application startup file – enter the .js file that runs the application.
- Passenger log file* – specify the path to store the error log.
You can also add Node.js environment variables and assign names and values to them.
When you save your first application, it will appear in the list of Node.js web applications.
From here, you’ll also be able to start, stop, restart, edit or delete your app.
* If it is a LiteSpeed web server, then you set up the Passenger log file directly by entering the command below in the .htaccess file (,located in the folder where the Application URL points):
PassengerAppLogFile "/home/vasadomain/mynode1/logs/passenger.log"
IMPORTANT: The root directory of the application in this example is “mynode1”; if you want to put the log in another subfolder (e.g. “logs”), you need to create this folder first.
The contents of the created .js file
Once you have entered the basic settings of the app and saved your changes in the previous step, the app has been created. A .js file with the following code has been created in the directory you specified:
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();
The result of the code is that when you visit the link to the application (vasadomena.si/app.js), the following lines are printed:
It works!
NodeJS 11.6.0
Note: The content of the second line depends on the selected version of the Node.js environment.
If you make certain changes to the code, you will need to restart the application. Otherwise, the link will still show you a printout of the application before the change was made.
Upload your application to the hosting package
Now that you have your Node.js environment ready, you can upload your application files to the hosting package. Upload them to the umbrella or “root” directory that you have previously defined.
If you also want to install specific modules, you can do so after entering the virtual environment of your application, via the SSH command line. The command to enter the virtual environment is shown on the application page.
For more information on SSH and how to enable the command line in My NEOSERV Subscription Centre, see the article Connecting to a hosting package with SSH.
At NEOSERV, we provide you with a stable and smooth-running Node.js environment powered by modern servers with powerful processors and built-in SSDs. So if you’re looking for a reliable Node.js hosting provider, don’t miss out on our great offer!






COMMENT THE POST
Your comment has been successfully submitted
The comment will be visible on the page when our moderators approve it.