Created
April 14, 2020 10:45
-
-
Save dimitrismistriotis/cd8702bd5f5241d91962f4155b7a16cd to your computer and use it in GitHub Desktop.
Latest nginx from repositories for Ubuntu script, for automatic deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ___ _ _ _ _ __ __ | |
# / __| ___| |_ _ _ _ __ | \| |__ _(_)_ _ \ \/ / | |
# \__ \/ -_) _| || | '_ \ | .` / _` | | ' \ > < | |
# |___/\___|\__|\_,_| .__/ |_|\_\__, |_|_||_/_/\_\ | |
# |_| |___/ | |
# | |
# References: | |
# | |
# * https://www.nginx.com/resources/wiki/start/topics/tutorials/install/ | |
# * https://www.svennd.be/gpg-nginx-signatures-verified-public-key-not-available/ | |
# | |
echo "Setup NginX" | |
release=`lsb_release -a 2>/dev/null | grep "Codename" | awk '{print $2}'` | |
sources_location="/etc/apt/sources.list.d/nginx.list" | |
temporary_location="./nginx.list" # Where script is run | |
echo "Current release: ${release}" | |
rm -f ${temporary_location} | |
# | |
# Locations from nginx's installation link | |
# | |
echo "deb https://nginx.org/packages/ubuntu/ ${release} nginx" >> ${temporary_location} | |
echo "deb-src https://nginx.org/packages/ubuntu/ ${release} nginx" >> ${temporary_location} | |
echo "" >> ${temporary_location} | |
sudo mv ${temporary_location} ${sources_location} | |
sudo chown root: ${sources_location} | |
ls -lah ${sources_location} | |
# | |
# Add signing key from Sven's blog, installation instructions cannot be scripted, | |
# eg: "if there is an error copy 'n' paste this." | |
# | |
curl -O http://nginx.org/packages/keys/nginx_signing.key | |
cat nginx_signing.key | sudo apt-key add - | |
rm nginx_signing.key | |
sudo DEBIAN_FRONTEND=noninteractive apt-get update | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nginx | |
echo "" | |
echo "Version of NginX installed:" | |
echo "" | |
nginx -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment