Skip to content

Instantly share code, notes, and snippets.

@yashtomer
Last active June 28, 2024 13:17
Show Gist options
  • Save yashtomer/e25721b226705316b3f1abbb01b5ac4d to your computer and use it in GitHub Desktop.
Save yashtomer/e25721b226705316b3f1abbb01b5ac4d to your computer and use it in GitHub Desktop.
Bootstrap AWS Setup
#! /bin/bash
export DEBIAN_FRONTEND=noninteractive
echo $'\n\e[32mInstalling essentails ...\e[0m\n'
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y curl wget vim build-essential software-properties-common apt-transport-https git
echo $'\n\e[32mInstalling Apache, PHP 5.6 and PHP 7.2 and PHP 8 ...\e[0m\n'
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y apache2 apache2-utils
#sudo apt install -y php5.6 libapache2-mod-php5.6 php5.6-mysql php5.6-pgsql php5.6-curl php5.6-gd php5.6-mcrypt php5.6-json php5.6-xml php5.6-gd php5.6-mbstring php5.6-dom php5.6-zip php5.6-soap php5.6-fpm php5.6-mcrypt
#sudo apt install -y php7.1 libapache2-mod-php7.1 php7.1-mbstring php7.1-xmlrpc php7.1-soap php7.1-gd php7.1-xml php7.1-cli php7.1-zip php7.1-bcmath php7.1-tokenizer php7.1-json php-pear php7.1-mysql php7.1-gettext php7.1-curl php7.1-memcached php7.1-xdebug php7.1-intl php7.1-fpm php7.1-pgsql php7.1-imap php7.1-mcrypt
#sudo apt install -y php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-pgsql php7.2-curl php7.2-gd php7.2-bcmath php7.2-xml php7.2-curl php7.2-json php7.2-mbstring php7.2-dom php7.2-zip php7.2-soap php7.2-fpm php7.2-mcrypt php7.2-intl
#sudo apt install -y php8.0 libapache2-mod-php8.0 php8.0-mysql php8.0-pgsql php8.0-curl php8.0-gd php8.0-mcrypt php8.0-xml php8.0-mbstring php8.0-zip php8.0-soap php8.0-fpm php8.0-common php8.0-cli php8.0-mongodb php8.0-bcmath php8.0-mcrypt php8.0-intl
sudo apt install -y php8.2 libapache2-mod-php8.2 php8.2-mysql php8.2-pgsql php8.2-curl php8.2-gd php8.2-mcrypt php8.2-xml php8.2-mbstring php8.2-zip php8.2-soap php8.2-fpm php8.2-common php8.2-cli php8.2-mongodb php8.2-bcmath php8.2-mcrypt php8.2-intl php8.2-gd php8.2-zip
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install -f
whereis wkhtmltopdf
echo $'\n\e[32mEnabling apache rewrite ...\e[0m\n'
sudo a2enmod rewrite
sudo systemctl restart apache2
echo $'\n\e[32mInstalling composer, Dependency Management for PHP ...\e[0m\n'
cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php /tmp/composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
composer --version
sudo chown -R www-data:www-data /var/www
sudo chmod -R 777 /var/www
echo $'\n\e[32mInstalling NODE Latest version via vnm ...\e[0m\n'
#curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
#sudo apt-get install -y nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm -v
nvm install 14.15.1
nvm alias default 14.15.1
npm install -g @angular/cli
echo $'\n\e[32mInstallation mongoshll!) \e[0m\n'
sudo rm -rf /var/lib/mongodb/*
sudo rm -rf /data/db/*
sudo apt-get install gnupg curl
curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl daemon-reload
sudo systemctl status mongod
sudo systemctl enable mongod
sudo systemctl stop mongod
sudo systemctl restart mongod
echo $'\n\e[32mInstallation redis!) \e[0m\n'
sudo apt install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis
redis-cli
ping
echo $'\n\e[32mInstallation awscli!) \e[0m\n'
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
which aws
aws --version
aws configure set aws_access_key_id "fakeMyKeyId" --profile user2 && aws configure set aws_secret_access_key "fakeSecretAccessKey" --profile user2 && aws configure set region "ap-south-1" --profile user2 && aws configure set output "text" --profile user2
echo $'\n\e[32mInstallation dynamodb!) \e[0m\n'
sudo apt install default-jre
java -version
wget https://d1ni2b6xgvw0s0.cloudfront.net/v2.x/dynamodb_local_latest.tar.gz
sudo mkdir -p /usr/lib/dynamodb
sudo mv dynamodb_local_latest.tar.gz /usr/lib/dynamodb/
cd /usr/lib/dynamodb/
sudo tar xfz dynamodb_local_latest.tar.gz
ls
sudo touch /etc/systemd/system/dynamodb.service
cat <<EOT >> /etc/systemd/system/dynamodb.service
[Unit]
Description=Dynamo DB Local Service
[Service]
User=root
# The configuration file application.properties should be here:
#change this to your workspace
WorkingDirectory=/usr/lib/dynamodb
#path to executable.
#executable is a bash script which calls jar file
ExecStart=/usr/lib/dynamodb/dynamodb
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOT
sudo touch /usr/lib/dynamodb/dynamodb
sudo cat <<EOT >> /usr/lib/dynamodb/dynamodb
#!/bin/sh
sudo java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8500
EOT
sudo chmod +x /usr/lib/dynamodb/dynamodb
sudo systemctl daemon-reload
sudo systemctl enable dynamodb
sudo systemctl start dynamodb
sudo systemctl status dynamodb
aws dynamodb list-tables --endpoint-url http://localhost:8500
aws dynamodb create-table --table-name task_status_mappings --attribute-definitions AttributeName=task_id,AttributeType=N --key-schema AttributeName=task_id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 --endpoint-url http://localhost:8500
echo $'\n\e[32mInstallation wine and sqlyog!) \e[0m\n'
dpkg --print-architecture
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
sudo apt update
sudo apt install --install-recommends winehq-stable
wine --version
#download sqlyog from below url
#https://drive.google.com/drive/u/0/folders/1xQR8U8Bxk4-MroFryiKTuMaCdxtFbxZi
#and right ckick sql.exe with run from wine
echo $'\n\e[32mInstallation putty-tools!) \e[0m\n'
sudo apt-get install putty-tools
#puttygen pemKey.pem -o ppkKey.ppk -O private
echo $'\n\e[32mInstallation Completed! Thank you. :) \e[0m\n'
@yashtomer
Copy link
Author

yashtomer commented Jun 11, 2021

Installation via curl

curl -sS https://gist.githubusercontent.com/yashtomer/e25721b226705316b3f1abbb01b5ac4d/raw/8bb6063ed9e1818ee19bc962c52b061697998315/awsbootstrap.sh | bash

Or, Installation via wget,

wget -O - https://gist.githubusercontent.com/yashtomer/e25721b226705316b3f1abbb01b5ac4d/raw/8bb6063ed9e1818ee19bc962c52b061697998315/awsbootstrap.sh | bash

@yashtomer
Copy link
Author

yashtomer commented Jun 11, 2021

Also, enable/disable phpmod as per requirement

sudo a2dismod php5.6
sudo a2dismod php7.2

sudo a2enmod php8.0

sudo systemctl restart apache2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment