setting up prod env in ubuntu

setting up prod environment in ubuntu

Install Nginx

commands – https://www.nginx.com/blog/setting-up-nginx/

sudo wget http://nginx.org/keys/nginx_signing.key
sudo nano /etc/apt/sources.list

# add
deb http://nginx.org/packages/ubuntu trusty nginx
deb-src http://nginx.org/packages/ubuntu trusty nginx

sudo apt-get update
sudo apt-get install nginx
sudo service nginx start

Install node js

commands – https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04)

cd ~
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
nano nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential

Install pm2

sudo npm install pm2@latest -g
pm2 startup
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu

Run the code

git http://{user-name}:{password}@gitlab.m-sas.com/{xxx}.git
npm install
NODE_ENV=prod pm2 start app.js --name api-prod

Ready to restart

pm2 save
Advertisements

About sunnyparkash
A Technoalcholic

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: