Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Step 1: Install Prerequisites:
yum groupinstall 'Development Tools' -y
Step 2: Install Yum Repository
NodeJS 12.x:
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
NodeJS 11.x:
curl -sL https://rpm.nodesource.com/setup_11.x | bash -
NodeJS 10.x:
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
NodeJS 8.x:
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
Step 3: Install Nodejs and npm
yum install -y nodejs
Step 4: Confirm installation:
Run the below commands to check if nodejs is installed properly:
node -v npm -v
The above command should output the version of nodejs and npm installed. For example, for version 12.X, you should see something like below:
[root@cwp2 ~]# node -v v12.6.0 [root@cwp2 ~]# npm -v 6.9.0
npm which is the package manager for nodejs can be used to search and install additional modules for nodejs.
npm search <package> npm install <package>
Step 5: Setup webserver to host Nodejs Application
These options depend on the webservers you have currently installed
Example if you have installed nginx/varnish/apache you can use:
i. nginx -> custom port - This will proxy directly to nodejs Application(RECOMMENDED)
ii. nginx/varnish -> custom port - This will proxy to varnish cache and then to nodejs Application
iii. nginx/varnish/apache -> custom port - This will proxy to varnish cache and then to apache and then to nodejs Application
Configure webservers for domain to be used for nodejs Application:
CWP.Admin left Menu -> Webserver settings -> Webserver Domain Conf -> Select Username -> Select Domain/Subdomain -> create configuration -> select any option with (custom port) -> check the box – Rebuild webserver conf for domain on save -> Enter port number you have used in the application for the custom port, leave IP as 127.0.0.1 -> save changes
Step 6: Install AutoSSL
CWP.Admin left Menu -> Webserver settings -> SSL Certificates -> AutoSSL -> select user and domain -> install SSL