Scripts & Guide for LEMP stack with Pagespeed and http2 modules - on ubuntu 18.04LTS or 20.04LTS
- mariadb - 10.6
- nginx - 1.20.0
- openssl (20.04) - 1.1.1k
- pagespeed-version - 1.13.35.2-stable
- php-version - 7.4
- ubuntu 20.04 (focal)
If you want to override these:
Go to folder config/versions
and add new files with override prepended eg. override-php-version
and use this setup guide.
This method accepts the default versions. Read the setup guide for using overrides here.
This is where you want to setup the environment.
Recommended to ssh into your server with agent forwarding ie ssh root@yourip -A
cd /var/www/
, or where you want your websites to live.
sudo apt-get install wget
wget https://raw.githubusercontent.com/amurrell/LEMP-setup-guide/main/install/install
sudo chmod +x install
./install
Jump down to: During & After The Script
First, ssh
into your server and navigate to your website installation location, eg. cd /var/www/
.
Recommended to ssh into your server with agent forwarding ie ssh root@yourip -A
git clone https://github.com/amurrell/LEMP-setup-guide.git
cd LEMP-setup-guide/config/versions
# see the services
ls
# look at one of them
cat php-version
# create override file
echo "8.0" > override-php-version
Note: 18.04 LTS Ubuntu, use "bionic" in override-ubuntu-release-name
After you're done overriding versions, you can install!
cd scripts
chmod +x server-initial-setup.sh
./server-initial-setup.sh
-
You'll get prompted for your ssh public key (to setup authorized keys for easier ssh access)
-
(Only on 16.04 install,) You'll get prompted to setup mariadb password, just use "password" for now. After everything is installed, you can run
sudo mysql_secure_installation
and follow prompts to remove test databases, anonymous users, and change the root password to something more secure. -
If you choose to skip setting up a site, you can always run the setup-site script later from
/var/www/LEMP-setup-guide/scripts/
. You can setup multiple sites using this script, one per run.
The following scripts are used "per site" that you want to setup on your server. They prompt and guide you through their functionality.
- setup-site - sets up a site based on git repo, creates nginx / php as needed
- setup-logrotate (needs logrotate command and syslog user)
- install-cert - sets up certbot for ssl on your site, with option to update nginx or not - creates a cronjob to keep fetching. ideal if you want control over how certbot affects nginx conf files.
There are also components in the install
folder, which allow you to install other specific common tools, as well as your own custom scripts.
- composer
- pm2
- nvm
- redis
- postgressql
- custom
The custom scripts have a install
file that will loop through scripts in the scripts
folder. You can name these with numbers to create an order of when they will run.
- install - (running this will loop through scripts in
/scripts
- /scripts - Add bash scripts here, make sure to
chmod +x
them. eg.000-running-custom-scripts.sh
SimpleDocker is just an ubuntu 16.04 or 18.04 Docker Container that you can use to test the scripts in the scripts folder.
Just clone SimpleDocker into the root directory of this LEMP project and alter the docker-compose.yml file to make the volume like:
volumes:
- ../:/var/www/LEMP-setup-guide
Change the branch to 18.04 to use that version of SimpleDocker.
If testing with simple docker, you'll need to install apt-get -y install rsyslog
and apt-get -y install logrotate
to use setup-logrorate.