Skip to content

Instantly share code, notes, and snippets.

@JoniWeiss
Last active April 3, 2017 22:21
Show Gist options
  • Save JoniWeiss/aff48eff50f47507dd0ff66afcaf1269 to your computer and use it in GitHub Desktop.
Save JoniWeiss/aff48eff50f47507dd0ff66afcaf1269 to your computer and use it in GitHub Desktop.
Setting up NodeJS Server

Create an account on Digital Ocean

Create droplet using latest 64-bit version of Ubuntu

Install ssh public key and test ssh connectivity

ssh -i ~/.ssh/my_key [email protected]

Create new user

adduser joniweiss

Add new user to sudo group

usermod -aG sudo joniweiss

Create .ssh dir and copy public key to new user $HOME directory

su joniweiss
cd ~
mkdir .ssh
chmod 700 .ssh
cd .ssh
sudo cp /root/.ssh/authorized_keys .
chown joniweiss:joniweiss authorized_keys

Open a new shell window and test connectivity to new user account on droplet.

ssh -i ~/.ssh/my_key [email protected]

Disable root ssh capability

sudo vi /etc/ssh/sshd_config

PermitRootLogin: No

sudo service sshd restart

Install and Configure NGINX on Ubuntu

Install nginx

sudo apt-get install nginx

Start NGINX Service

sudo service nginx start

Goto IP address of server in browser. Should see something like:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

Install Git, NodeJS, and NPM

Git

sudo apt-get install git

NodeJS

sudo apt-get install nodejs

NPM

sudo apt-get install npm

Or all at the same time:

sudo apt-get install git nodejs npm

Create symbolic link for node --> nodejs

sudo ln -s /user/bin/nodejs /user/bin/node

Create www directory

sudo mkdir -p /var/www

Change www directory ownership

sudo chown -R joniweiss:joniweiss /var/www

Set-up App on Server

Create or Clone app into /var/www subdirectory

git clone https://github.com/young/Dev-Ops-for-Frontend.git
mv Dev-Ops-for-Frontend/ app

Run npm install

cd app
npm i

Edit Nginx sites file

sudo vi /etc/nginx/sites_available/default
goto location block
change to (use appropriate port for app):
  location / {
      proxy_pass http://127.0.0.1:3001/;
  }

Restart nginx

sudo service nginx restart

Create/edit gulp file

Install gulp

npm i -g gulp

Start server

node app.js

Go to app url in browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment