Skip to content

Instantly share code, notes, and snippets.

@sayanriju
Last active July 8, 2020 11:36
Show Gist options
  • Save sayanriju/6bd2452dc5ee7789cf9f3d53f150e2b8 to your computer and use it in GitHub Desktop.
Save sayanriju/6bd2452dc5ee7789cf9f3d53f150e2b8 to your computer and use it in GitHub Desktop.
Set up Digital Ocean Droplet for Node & MongoDB (optionally Redis)

Set up Digital Ocean Droplet for Node & MongoDB (optionally Redis)

Locale Setup

Append the following to the file /etc/environment:

LANG="en_US.UTF-8"  
LC_ALL="en_US.UTF-8"  
LANGUAGE="en_US.UTF-8" 

Then, either reboot droplet or run source /etc/environment

Add Swap

fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
cp /etc/fstab /etc/fstab.ORIG ## Backup!
echo '/swapfile none swap sw 0 0' >> /etc/fstab

Node

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt-get install -y nodejs
npm i -g pm2
## Run the command generated by:
pm2 startup	# Interactive command!

Mongo

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.6.list
apt-get update && apt-get install -y mongodb-org
systemctl start mongod
systemctl enable mongod

User Setup

adduser ls # Interactive command!
usermod -aG sudo,www-data ls
su - ls -c ssh-keygen # Interactive Command

Redis (Optional)

apt-get install redis-server redis-tools
systemctl restart redis-server.service
systemctl enable redis-server.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment