Install/Setup Nodejs 14.17.3(LTS) on cpanel

Install/Setup Nodejs 14.17.3(LTS) on cpanel



1. Log in to your account using SS

2. Download the NodeJS

wget https://nodejs.org/dist/latest/node-v14.17.3-linux-arm64.tar.xz

 

3. Extract

tar xvf node-v14.17.3-linux-arm64.tar.xz

 

4. Now rename the folder to nodejs name, to do this type the following command

mv node-v14.17.3-linux nodejs

 

5. Now install node and npm binaries, type the next commands:

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

 

6. Node.js and npm are installed on your account. To verify, type the following commands

node --version
npm --version

 

7. Start Node.js Application

npm start

 

9. Integrating a Node.js application with the web server(optional)

In a text editor, add the following lines to the .htaccess file in the/home/username/public_html directory

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

 

0 comments :

Post a Comment