在ubuntu 16.04上安裝Nginx和Let’s Encrypt

Install Nginx With Let’s Encrypt on Ubuntu 16.04

James Shieh
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 :

  1. A Ubuntu Server 16.4
  2. 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

--

--

James Shieh
James Shieh

Written by James Shieh

Find something more important than you are and dedicate your life to it.

No responses yet