在ubuntu 16.04上安裝Nginx和Let’s Encrypt
Install Nginx With Let’s Encrypt on Ubuntu 16.04
3 min readNov 5, 2019
Automatically install Nginx with Let’s Encrypt.
I wrote some scripts that could automatically install Nginx and Let’s Encrypt on Ubuntu 16.04. You only need to set some parameters in a .env
configuration file and just run the shell script.
Prerequisites
You need to prepare :
- A Ubuntu Server 16.4
- A Domain Name
Installing
sudo apt-get update
Clone this repository on your ubuntu server.
git clone https://github.com/JamesShieh0510/setup-machine.git
Set parameters in .env
file
cd ./setup-machine/ubuntu/nginx/
nano .env
In .env
, hostname is your domain name, email is your email, if redirect_https is true, nginx will make all requests redirect to secure HTTPs access:
metadata
description: nginx environment configuration
parameter:
hostname: <YOUR DOMAIN NAME>
email: <YOUR EMAIL>
redirect_https: <false|true> #If true Then Make all requests redirect to secure HTTPS access.
Running the script
Only install Nginx: If you want to install Nginx without Let’s Encrypt:
. ./install-nginx.sh
Install Nginx with Let’s Encript: If you want to install Nginx with Let’s Encrypt:
. ./install-nginx-with-lets-encrypt.sh