How to install nodejs

Install nodejs on linux

Install nodejs on ubuntu

Install nodejs on centos 7

Install nodejs and npm

What is Nodejs
Node.js is an open-source which runs on server-side and also a cross-platform JavaScript run-time environment for executing JavaScript code server-side.

How to Install Nodejs and How to use it with nginx server and apache server.

  • Nodejs installation in centos 6.5 , 6.6 , 6.7 , 7 and ubuntu ( in every linux distro )
  • Nodejs installation and configuration guidence for every available version ( 0.x , 6.x 8.x )
  • With this example you will get to know the installation of nodejs and installation process will be same for every version of nodejs

Each and every version of nodejs is available in below link,Download the version you want

http://nodejs.org/dist/

Installation of node-v0.10.42

First Download your version from here

http://nodejs.org/dist/v0.10.42/node-v0.10.42.tar.gz

Extract the nodejs setup

tar -zxf node-*.tar.gz
or
tar -zxvf node-*.tar.gz

cd node-*.tar.gz

Prepare the complier

./configure

Compile the configure setup

make

Install the configures setup (configure nodejs on Linux)

make install

How to check the version of nodejs and this will also confirm the installation

node --version
npm --version

Check the nodejs server port

netstat -ntlp

How to run nodejs server in background

npm install forever -g

netstat -ntlp

Run the scrpit in background



forever start socket.js

Check the nodejs server port

netstat -ntlp | grep node

Commonly users use 3000 and 3001 port for the nodejs server

How to uninstall the nodejs

yum remove nodejs

How to configure the nodejs server with nginx server

upstream mynode {
server localhost:3001;
}
server {
listen 80;
root /var/www/html/node;
index index.html index.php inde.htm;
server_name chirag.techouse.co.in;
error_log /var/log/nginx/chirag.local_error.log;

location / {
proxy_pass http://mynode;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

How to configure the nodejs in apache web server

Edit your virtualhost

vim /etc/httpd/conf.d/demo.techouse.co.in

Add the below lines in virtualhost

<VirtualHost *:80>
--------------
-------------
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://localhost:3001/
ProxyPassReverse http://localhost:3001/
</Location>

</VirtualHost>

install nodejs on centos 7install nodejs on linuxinstall nodejs and npm centos 7

For any doubts please comment below.

techouse

I love helping beautiful people like you. I love hanging out with my dogs.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

× How can I help you?