Web App LAMP Server Setup 2022

Install LAMP Software

sudo apt update && sudo apt upgrade

sudo apt install fail2ban apache2 mariadb-server php php-{cli,bcmath,bz2,curl,intl,gd,mbstring,mysql,zip}

sudo mysql_secure_installation

Install Certbot For SSL

To install SSL, use Certbot.

Install Resilio-Sync

Install Resilio Sync for Backup transportation and versioning;

https://help.resilio.com/hc/en-us/articles/206178924-Installing-Sync-package-on-Linux

Add Scripts For Backups And Permissions

Various scripts and files (That go in various places)

https://github.com/cjtrowbridge/vps-home

cd ~

wget https://raw.githubusercontent.com/cjtrowbridge/vps-home/master/backups.sh

chmod +x backups.sh

wget https://raw.githubusercontent.com/cjtrowbridge/vps-home/master/fix_permissions.sh

chmod +x fix_permissions.sh

Set up Daily Backups

Add this line to the end of /etc/crontab

0 0 * * * root bash “/root/backups.sh”

Set up Automatic Off-Site xfer

Create a Resilio-Sync shared folder on your NAS and then put the RW key in the cj.conf file from the repository above and put that file in /etc/resilio-sync/cj.conf

cd /etc/resilio-sync/

wget https://raw.githubusercontent.com/cjtrowbridge/vps-home/master/cj.conf

Put the RW key in the cj.conf file…

rslsync –config /etc/resilio-sync/cj.conf

Test Backups

Run the ~/backups.sh and watch the resilio dashboard on your NAS to see if traffic starts coming in. Viola!

Database Memory and CPU Optimizations

I like to use these optimizations to minimize resource consumption and virtual machine costs.