How to run node js file on hosting server? JavaScript is one of the popular and famous programming languages used for building a node.js web hosting page, web application and many more. For building a reliable server browser and application on the server then your need to use Node js. 

Node js event-driven, open-source, cross-stage runtime JavaScript platform and environment for design or building up various combinations of web pages and applications. 

Run node.js file on hosting server is essentially used for hosting various kinds of applications like the blogging stage etc. In this article, we will see how we can build a Node JS file application on shared hosting server.    

Run Node.js file on Hosting Server.

Building and run Node js on the hosting server is one thing. In this article, we explain to you how to run node js file on hosting server. To install node js file on hosting server first you need to run command line on your node js server. 

These are the simple steps follow to run node.js file on hosting server and install node js and npm on the shared hosting server. We explain steps to run node js on Linux server by using Node Version. 

Step 1:- Access SSH Command Line

To install the node js application on Linux server, we need SSH access. To create SSH access key on the cpanel hosting account and then you can simply able to SSH access form your best ssd web hosting terminals (Command line). To create SSH access of your server ask your host provider.

ssh -p port username@IpAddress

Step 2:- On your web hosting server account, you need to access the root directory.

Now navigate the root directory. Go to home folder and download the node.js file.

# cd ~
# wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.xz
 

Select the downloading file 

# tar -xvf node-v6.9.1-Linux-x64.tar.xz

The selected file or extracted directory, Rename it to project name of Node js

# mv node-v6.9.1-Linux-x64 nodejs

Step 3:- The next step and procedure are to installing node and npm binaries. Just copy/paste by executing the following commands.

# mkdir ~/bin
# cp -r nodejs/bin/node ~/bin 
# cd ~bin 
# ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm
 

You can run node js and npm in the ~/bin directory is the default path in your account.

Step4:- Finally, successfully run and install the node js and npm on a shared hosting server. By using the command line, you can easily verify by same.

#node –version
#npm –version

Step5:- By using this below two methods, you start node. These two are using npm and running node directory.

Using npm-
# nohup npm start –production & 
Running node directly- 
# nohup node my_app.js & 

“&” – Show for the command in the background. 

“Nohup” – the term shows the application will run regularly if you log out from the terminal session.

Note – Don’t neglect to replace “my_app.js” with your node application file name.

Step6:- To stop the node.js application, the below command line will stop the node js application immediately. 

 # pkill node

This command-line execute for the quick stop node js application.

The following command line used to open the .htaccess file and run node.js.

 # vi /home/username/public_html/.htaccess

After that copy the below info in the file

 RewriteEngine On
 RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L] 
 RewriteCond %{REQUEST_FILENAME} !-f 
 RewriteCond %{REQUEST_FILENAME} !-d 
 RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]

Note: Don’t forget to replace the “XXXXX” with the port you set in your app.

In this article, we run node js on server command Node v6.9.1. Version. Also, we learn about npm and creating node js application on the webserver.    

What is SSH Command?

SSH Access stands for Secure Shell or Secure Socket Shell. SSH is a network protocol that permits users to connect and access securely over the unsecured networks.

  • In addition to install node js on server, it provides a secure network protocol that suite of utilities that perform the SSH compact.
  • It often used for remote terminal connections and gives you to access a text-mode terminal on a remote computer.  
  • The SSH network protocol will be capable to manage the server by typing commands on your local computer.

Top Advantages of Node.js for Developers and Enterprises

  • Performance and Scalability
  • Extensibility
  • Building Cross-Functional Teams
  • Fast-processing and event-based model
  • Strong corporate support
  • Improved App Response Time
  • Boosted Web App Development Speed
  • Seamless JSON support
  • Robust technology stack
  • Single Programming Language

If you are using Windows, you will need to utilize an SSH or in order to install node js run server command an SSH connection. First, you require the most popular component is Putty. In order to use Linux or Mac, you need to SSH command line

LEAVE A REPLY

Please enter your comment!
Please enter your name here