Skip to content

Instantly share code, notes, and snippets.

@tiero
Last active January 28, 2020 22:23
Show Gist options
  • Save tiero/9c126f156bd3f26c22e033208bd0e094 to your computer and use it in GitHub Desktop.
Save tiero/9c126f156bd3f26c22e033208bd0e094 to your computer and use it in GitHub Desktop.
Install Node, Nginx and CodeDeploy on AWS EC2 instance with Ubuntu 16.04
#!/bin/bash
sudo apt-get update -y
sudo apt-get install wget
# Install web server stuff
sudo apt-get install -y nginx
# Locale settings for python
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
# Python
sudo apt-get --quiet install --yes python-pip
python -m pip install awscli --user
#Ruby for codedeploy
sudo apt-get install ruby -y
# Get basic details of the running instance
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`"
EC2_ZONE="`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone`"
EC2_REGION="`echo $EC2_ZONE | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
# Install CodeDeploy Agent
cd ~
wget https://aws-codedeploy-${EC2_REGION}/latest/install
chmod +x ./install
sudo ./install auto
# Using NVM bash script install node and npm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
# Install git
sudo apt-get install -y git
# Start nginx
sudo service nginx start
# Start CodeDeploy Agent
sudo service codedeploy-agent start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment