Skip to content

Instantly share code, notes, and snippets.

@felipecsl
Last active August 25, 2022 23:06
Show Gist options
  • Save felipecsl/d44b9b29d706f5bd29df43b9e2707e5a to your computer and use it in GitHub Desktop.
Save felipecsl/d44b9b29d706f5bd29df43b9e2707e5a to your computer and use it in GitHub Desktop.
Base EC2 instance setup for Amazon Linux box
# Install all the packages
sudo yum install -y \
curl gpg gcc gcc-c++ make git \
openssl-devel readline-devel libcurl-devel \
zlib-devel postgresql-server.x86_64 ruby-devel \
sqlite sqlite-devel ruby-rdoc python-devel \
cairo-devel libffi-devel python-pip nc docker \
tmux htop postgresql-libs postgresql-devel \
amazon-cloudwatch-agent
# openjdk 11
sudo amazon-linux-extras install java-openjdk11
# install rbenv and ruby
# steps below from https://gist.github.com/luisbebop/71744181980fdd9372c0e85ab8c7299d
git clone git://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build system-widely
git clone git://github.com/rbenv/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
sudo ./install.sh
rbenv install <ruby_version>
# install fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# install nvm/node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
# install yarn
npm install --global yarn
# reload terminal
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install node
# install jdk-8
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm
sudo yum install -y jdk-8u141-linux-x64.rpm
# enable memory swap (important for micro/nano instances)
# https://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/
# install nginx (needed for letsencrypt setup)
sudo amazon-linux-extras install nginx1.12 -y
sudo service nginx start
# check config file
sudo nginx -t
# install postgres 10
sudo amazon-linux-extras install postgresql10 vim epel -y
sudo /usr/bin/postgresql-setup --initdb
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo -u postgres -i
psql
# run below in psql:
# CREATE ROLE "ec2-user" LOGIN;
# CREATE DATABASE "ec2-user";
# ALTER USER "ec2-user" createdb;
# instal letsencrypt
# add snippet below to server section of your nginx.conf file (/opt/nginx/conf/nginx.conf)
# location ~ /.well-known {
# allow all;
# root /var/www/letsencrypt;
# }
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# follow https://medium.com/@andrenakkurt/great-guide-thanks-for-putting-this-together-gifford-nowland-c3ce0ea2455
sudo /opt/letsencrypt/certbot-auto certonly --webroot -w /var/www/letsencrypt -d <domain_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment