Speaking of DevOps practices like infrastructure automation,there are many nice instruments on the market for giant enterprise purposes. Nevertheless, for small purposes, it might be an overkill like utilizing a sledge hammer for a fly. So why would I take advantage of Infrastructure as Code System corresponding to Terraform, or Configuration Administration System Chef, Ansible, Puppet; once I can merely fly with this 5mins set up information š (simply kidding, I’m studying them š)
I often replace the set up steps so get the Github gist for the latest.
š nonetheless drafting the article
#!/usr/bin/env bash
# Steps to write down and execute a script
# Open the terminal. Go to the listing the place you need to create your script.
# Create a file with . sh extension.
# Write the script within the file utilizing an editor.
# Make the script executable with command chmod +x <fileName>.
# Run the script utilizing ./<fileName>.
echo "
----------------------
Including a New Consumer to the System 'Sammy'
----------------------
"
adduser sammy
# enter all of the prompted data
# Step 3 ā Including the Consumer to the sudo Group
usermod -aG sudo sammy
# Testing sudo Entry
su - sammy
sudo ls -la /root
echo "
----------------------
GIT
----------------------
"
# set up curl
sudo apt set up curl -y
# set up git
sudo apt-get set up -y git
echo "
----------------------
NODE & NPM
----------------------
"
## You might also want growth instruments to construct native addons:
sudo apt-get set up gcc g++ make -y
wget -qO- https://uncooked.githubusercontent.com/nvm-sh/nvm/v0.38.0/set up.sh | bash
nvm ls-remote
nvm set up 14
nvm alias default 14.15.0
# add nodejs 14 ppa (private package deal archive) from nodesource
# curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
# set up nodejs and npm
# sudo apt-get set up -y nodejs
echo "
----------------------
MONGODB
----------------------
"
# import mongodb 4.0 public gpg key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
# create the /and so forth/apt/sources.record.d/mongodb-org-4.0.record file for mongodb
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /and so forth/apt/sources.record.d/mongodb-org-4.0.record
# reload native package deal database
sudo apt-get replace
# set up the most recent model of mongodb
sudo apt-get set up -y mongodb-org
# begin mongodb
sudo systemctl begin mongod
# cease mongodb
sudo systemctl cease mongod
# Make a listing as root person
sudo mkdir -p /information/db
# Present entry to the listing
sudo chown -R $USER /information/db
# set mongodb to begin robotically on system startup
sudo systemctl allow mongod
# cease mongodb to begin robotically on system startup
sudo systemctl disable mongod
# set up native replication-set driver for nodejs
sudo npm set up --unsafe-perm --verbose -g run-rs -f
# begin mongodb reproduction set
# run-rs --mongod --keep --shell --dbpath /house/person/information"
# begin mongod as a background course of
mongod --fork --syslog
echo "
----------------------
PM2
----------------------
"
# set up pm2 with npm
npm set up -g pm2
# set pm2 to begin robotically on system startup
pm2 startup systemd
# make present person the proprietor of the pm2 log house dir
sudo chown -R $(whoami):$(whoami) /house/ubuntu/.pm2
# create a shell script reproduction.sh
$ nano reproduction.sh
#!/bin/bash
run-rs --mongod --keep --shell --dbpath /information/db
$ pm2 run reproduction.sh
echo "
----------------------
NGINX
----------------------
"
# set up nginx
sudo apt-get set up -y nginx
# You can also make the currrent $USER the proprietor of that listing
sudo chown -R $(whoami):$(whoami) /var/www
# set the suitable permissions
chmod 755 -R /var/www
echo "
----------------------
UFW (FIREWALL)
----------------------
"
# enable ssh connections by firewall
# sudo ufw enable OpenSSH
# enable http & https by firewall
# sudo ufw enable 'Nginx Full'
# allow firewall
# sudo ufw --force allow
echo "
----------------------
NETWORK TESTING TOOL
----------------------
"
# curl software
sudo apt set up httpie -y
sudo apt replace
sudo apt set up redis-server -y
# # remark out `supervised no` and set `supervised systemd`
sudo nano /and so forth/redis/redis.conf
# > supervised systemd
# restart redis server
sudo systemctl restart redis.service
echo "
----------------------
SET UP LETS-ENCRYPT
----------------------
"
# Instal CertBot
curl -o- https://uncooked.githubusercontent.com/vinyll/certbot-install/grasp/set up.sh | bash
# Open the server block file in your area utilizing nano or your favourite textual content editor:
sudo nano /and so forth/nginx/sites-available/instance.com
#server_name instance.com www.instance.com;
# take a look at and restart nginx
sudo nginx -t
sudo systemctl reload nginx
# create the nginx default configuration
nano default
# paste the content material under
## begin š„
# web site server
server {
server_name instance.com www.instance.com;
root /var/www/html/internet/construct;
index index.html;
location / {
try_files $uri$args $uri$args/ /index.html;
}
}
# admin console server
server {
server_name admin.instance.com;
root /var/www/html/admin/dist;
index index.html;
location / {
try_files $uri$args $uri$args/ /index.html;
}
}
# demo or documentation server
server {
server_name builders.instance.com;
root /var/www/html/backend/doc;
index index.html;
location / {
try_files $uri$args $uri$args/ /index.html;
}
}
# backend api server
server {
server_name api.instance.com;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Improve $http_upgrade;
proxy_set_header Connection 'improve';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
}
## finish š¤
sudo rm /and so forth/nginx/sites-available/default
sudo mv default /and so forth/nginx/sites-available/default
# Arrange Certbot to acquire SSL certificates
sudo certbot --nginx -d instance.com -d www.instance.com -d api.instance.com -d dev.instance.com -d builders.instance.com -d admin.instance.com
# To check the renewal course of, you are able to do a dry run with certbot:
sudo certbot renew --dry-run