Skip to content

Instantly share code, notes, and snippets.

@stephenhuh
Last active June 20, 2018 04:25
Show Gist options
  • Save stephenhuh/80ccdcd285b51ef5beb16871c91d8ee7 to your computer and use it in GitHub Desktop.
Save stephenhuh/80ccdcd285b51ef5beb16871c91d8ee7 to your computer and use it in GitHub Desktop.
Setting up Amazon Linux AMI via Lightsail for Node & Express
#!/bin/bash
# Amazon_Linux-512MB-Virginia-1-Personal
# 512 MB RAM, 1 vCPU, 20 GB SSD
# Amazon Linux
# Virginia, Zone A (us-east-1a)
# Exit on any error (non-zero return code)
set -e
# Below commands are easier to run via root.
sudo su
yum update -y
yum install -y gcc gcc-c++ make openssl-devel
cd /tmp
curl -O https://nodejs.org/dist/v10.4.1/node-v10.4.1-darwin-x64.tar.gz
tar -xvf node-v10.4.1.tar.gz && rm node-v10.4.1.tar.gz
# chances are you need higher memory, use a swapfile
# fallocate or dd work here (note there r differences w holes)
# Create swapfile of 2GB with block size 1MB
/bin/dd if=/dev/zero of=/mnt/2GB.swap bs=1024 count=2097152
mkswap /mnt/2GB.swap
swapon /mnt/2GB.swap
# Setup Node
cd /tmp/node-v10.4.1
./configure
make
make install
# Create Web Directory with a "Devops"-like group.
adduser shuh #or whatever ur name is.
groupadd devops
groupadd -aG devops shuh
mkdir /var/www/src -p
cd /var/www && chgrp devops src
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cd /.ssh
# Add your pub key to GitHub or like-system.
cat id_rsa.pub
cd /var/www/src
git clone [email protected]:stephenhuh/personal.git #Or whatever repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment