-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntuServerNginxCertbot
36 lines (27 loc) · 1.36 KB
/
ubuntuServerNginxCertbot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
sudo apt update
sudo apt install -y nginx certbot python3-certbot-nginx
#Nginx
Echo " Install the prerequisites: "
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
Echo " Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:"
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "Verify that the downloaded file contains the proper key:"
gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "If you would like to use mainline nginx packages, run the following command instead:"
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
echo "Set up repository pinning to prefer our packages over distribution-provided ones:"
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
echo " now installing nginx mainline..."
sudo apt update
sudo apt install nginx
# Certbot
sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx