Skip to content

Instantly share code, notes, and snippets.

@dostiharise
Created March 28, 2018 13:49
Show Gist options
  • Save dostiharise/8008bc72519406a634efacf278d9b5c6 to your computer and use it in GitHub Desktop.
Save dostiharise/8008bc72519406a634efacf278d9b5c6 to your computer and use it in GitHub Desktop.
Script to upgrade nginx on Ubuntu using nginx packages.
# Setup a build directory
mkdir ~/nginx-build && cd ~/nginx-build
# Backup nginx config files
sudo mkdir /etc/nginx-backup
sudo cp -r /etc/nginx/* /etc/nginx-backup
# Note down nginx version and details
nginx -V
# Install utils to manage apt sources
sudo apt install software-properties-common
# Add nginx package signing key
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
# Add nginx package sources
. /etc/os-release
sudo add-apt-repository 'deb http://nginx.org/packages/mainline/ubuntu/ $UBUNTU_CODENAME nginx'
# Stop nginx
sudo service nginx stop
# Update and install nginx
sudo apt update
sudo apt install ngnix
## Select 'N' (No) for overwrite /etc/nginx/nginx.conf
# Start nginx
sudo service nginx start
# Verify latest nginx version
nginx -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment