Skip to content

Instantly share code, notes, and snippets.

@snakers4
Last active April 23, 2017 08:02
Show Gist options
  • Save snakers4/254177ef470e102256898ee558d7ecba to your computer and use it in GitHub Desktop.
Save snakers4/254177ef470e102256898ee558d7ecba to your computer and use it in GitHub Desktop.
# update reps
sudo apt-get update
# installation of the key software
# SOFTWARE
# server monitoring tool
sudo apt-get install glances
# just invoke glances to monitor the system
# FIREWALL
# configuring ufw with basic posrts and apps
sudo ufw allow ssh
sudo ufw allow ftp
sudo ufw allow ssh
sudo ufw allow from your_api to any port 5432
sudo ufw allow from server_ip to any port 5432
sudo ufw allow 80/tcp
# POSTGRES INSTALLATION
# installing contrib version via ppa
sudo apt-get install postgresql postgresql-contrib
# APACHE2
# installing apache2
sudo apt-get install apache2
# checking syntax of apache2 config files
sudo apache2ctl configtest
sudo systemctl status apache2
# restarting apache2
sudo systemctl restart apache2
# apache2 specific mods
sudo a2enmod proxy # for reverse proxy
# HERE YOU CONFIGURE YOUR APACHE2 VIRTUAL HOSTS
# checking ufw
sudo ufw app list
# disable apache2 directory listing mod
sudo a2dismod autoindex -f
# PHP INSTALLATION
# install php
# https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
sudo apt-get install php libapache2-mod-php php-mcrypt
# install postgresql driver
sudo apt-get install php-pgsql
# install curl
sudo apt-get install php-curl
# locate the php.ini file ans set
# do your php.ini config here
# NODE JS
# installing node js and npm
sudo apt-get install nodejs
# this actually installs node 4.3
# do this to install 6.9+
wget -qO- https://deb.nodesource.com/setup_7.x | sudo bash -
sudo apt-get install -y nodejs
# install yarn
# https://yarnpkg.com/lang/en/docs/install/#linux-tab
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
# disable the apache2 default conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
# TEAM FTP ACCESS
# # vsftpd installation and config
sudo apt-get install vsftpd
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.original
sudo nano /etc/vsftpd.conf
# key changes
# uncomment local_umask=022
# local_enable=YES
# write_enable=YES
# anonymous_enable=NO
# chroot_local_user=YES
sudo adduser spark-in-me
sudo chown spark-in-me:spark-in-me /var/www/spark-in-me/
sudo usermod -d /var/www/spark-in-me spark-in-me
sudo chmod a-w /var/www/spark-in-me
sudo service vsftpd restart
chown spark-in-me:spark-in-me /var/www/spark-in-me/blog/
chown spark-in-me:spark-in-me /var/www/spark-in-me/admin/
# after this commands vsftpd should start properly working
# crontab setup and usage
crontab -e
# CRONTAB CONTENTS START HERE
# Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
[email protected]
#End borrowed from anacron
# 0 1 * * * /home/snakers41/bash-scripts/WHOLE_SYSTEM_BACKUP.sh
# CRONTAB CONTENTS END HERE
# backups
# plain backup script
mkdir /home/bash-scripts
mkdir /media/backups
sudo nano /home/bash-scripts/WHOLE-SYSTEM-BACKUP.sh
# SCRIPT STARTS HERE
# http://help.ubuntu.ru/wiki/backup#восстановление_из_архива
#/bin/bash
#Purpose = Whole system backup
#Created on 25-08-2016
#Last modified on 29-08-2016
#Author = [email protected]
#Version 1.1
#START
# This Command will add date in Backup File Name.
TIME=`date +%b-%d-%y`
# Here i define Backup file name format.
FILENAME=test-system-backup-$TIME.tar.gz
# Backed up folder (system root) location
SRCDIR=/
# Destination of backup file
DESDIR=/media/backups
# exclude folder list
EXCLUDE='--exclude=/media/server --exclude=/media/ext_storage --exclude=/media --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys'
# Do not include files on a different filesystem
ONEFSYSPARAM='--one-file-system'
# test command validity
# echo -e tar -cvpzf $DESDIR/$FILENAME $EXCLUDE $ONEFSYSPARAM $SRCDIR
sudo tar -cpzf $DESDIR/$FILENAME $EXCLUDE $ONEFSYSPARAM $SRCDIR
echo "WHOLE_SYSTEM_BACKUP is successful: $(date)" >> /home/bash-scripts/cron_log.log
#END
# SCRIPT ENDS HERE
# EMAIL ALERTS
# email alerts set-up - useful for cron
sudo apt-get install ssmtp
# START CONFIG
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# root=postmaster
root=gmail-addresscom
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# mailhub=mail
mailhub=smtp.gmail.com:587
AuthUser=gmail-addresscom
AuthPass=your_pass
UseTLS=YES
UseSTARTTLS=YES
# Where will the mail seem to come from?
rewriteDomain=gmail.com
# The full hostname
# hostname=snakers41-ubuntu
hostname=localhost
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
# END CONFIG
# IMPORTANT - turn on less secure apps in google account settings
# https://support.google.com/accounts/answer/6010255
# test email
# echo "Test message from Linux server using ssmtp" | sudo ssmtp -vvv [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment