Skip to content

Instantly share code, notes, and snippets.

@wswoodruff
Created October 6, 2019 22:25
Show Gist options
  • Save wswoodruff/4be829776ef6e41ad2516494c870e2da to your computer and use it in GitHub Desktop.
Save wswoodruff/4be829776ef6e41ad2516494c870e2da to your computer and use it in GitHub Desktop.
Setup notes for Ec2 amazon_linux box
================================
Administrative
================================
INFO:
---------------
$ uname -a
Linux ip-xxx-xx-xx-xx.ec2.internal 4.14.138-114.102.amzn2.x86_64 #1 SMP Thu Aug 15 15:29:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
---------------
Initial Maintenance
$ sudo yum update
================================
Setup node
================================
$ sudo yum install gcc-c++ make -y
$ sudo yum install openssl-devel -y
$ sudo yum install git -y
$ sudo chown -R :wheel /usr/local/lib
$ sudo chmod -R g+rwx /usr/local/lib
$ cd /usr/local/lib
Visit https://nodejs.org to get the latest version
$ wget https://nodejs.org/dist/v12.11.1/node-v12.11.1.tar.gz
$ tar -xvf node-v12.11.1.tar.gz
$ rm node-v12.11.1.tar.gz
$ cd node-v12.11.1
$ ./configure && make && sudo make install
-- This will run for a really long time, it's compiling node from the source
- I mean like it could take over an hour
Fix perms
$ sudo usermod -aG wheel ec2-user
$ sudo chown :wheel -R /usr/local/lib
$ sudo chmod -R g+rw /usr/local/bin
Not a fix but just useful
$ sudo chown :wheel /usr/bin
$ sudo chown :wheel /usr/lib
$ sudo chown -R :wheel /usr/local
$ sudo chmod -R g+rw /usr/local
-- After ensuring npm is installed, you can install `n` to manage the node version on the server
$ npm install -g n
$ n latest
================================
npm
================================
When I installed node above, npm and npx came with it! Installed in /usr/local/bin where I would have wanted it.
In case that doesn't happen:
Wait for Node to be fully compiled
$ sudo su - # switch user to root
$ cd /usr/local/lib
$ wget http://npmjs.org/install.sh
$ chmod +x install.sh
$ ./install.sh
$ sudo chown -R :wheel /usr/local/lib/node_modules
================================
nginx
================================
$ sudo amazon-linux-extras install nginx1.12
To restart nginx
$ sudo service nginx restart
Now follow steps in another tutorial to setup your nginx config stuff
================================
certbot-auto
================================
$ cd /usr/local/bin
$ wget https://dl.eff.org/certbot-auto
$ sudo chmod +x certbot-auto
$ sudo chmod 0755 certbot-auto
$ sudo su -
$ mv certbot-auto /usr/bin
$ certbot-auto
- You will probably get this awful message!!
- Sorry, I don't know how to bootstrap Certbot on your operating system!
- Fix by editing the file
- $ sudo vim ./certbot-auto
- Search for the line that reads:
elif [ -f /etc/redhat-release ]; then
- Replace with
elif [ -f /etc/redhat-release ] || grep 'cpe:.*:amazon_linux:2' /etc/os-release > /dev/null 2>&1; then
- Then run again!
Do whatever certbot configuration u can figure out
-----------------------
Setup cron for renewal
-----------------------
Should still be root user
$ crontab -e
30 15 * * * root certbot-auto renew && service nginx restart
$ service crond restart
================================
bash aliases n stuff
================================
# This file gets loaded on login by all users
$ sudo vim /etc/bashrc
At the end of the file add whatever like:
alias ll="ls -l"
alias la="ls -al"
git config --global alias.s 'status'
git config --global alias.c 'commit'
git config --global alias.a 'add --all'
# Lets you type .. to go up a dir, or type a dir name to cd to it
shopt -s autocd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment