Hello there, in this short article i will be just documenting how to update an NGINX server to the latest version for the Ubuntu OS.
Easy Short Way
Originally NGINX comes bundled with some Ubuntu versions. For the purpose of this article, I will be using the official Ubuntu 18.04 that didn’t come with the included NGINX server.
So first thing to do would be to check if you already have NGINX server installed which you can do with command:
sudo -v
Compare that to the version number on NGINX homepage to see if you have the latest version.
After that if you still need to update from the official nginx/stable repo just run:
sudo apt update
sudo apt install nginx
Harder Long Way
If you follow the procedure from above you still might get few version lower than what you’ve seen on the NGINX homepage.
So what you have to do essentially is to add repo and key manually and try the mainline NGINX packages. So let’s get started with the procedure.
Before we go in, need to make sure you have all the prerequisites installed. Go and run this command:
sudo apt install curl gnupg2 ca-certificates lsb-release
To set up the apt repository for stable NGINX packages, you can run the following command:
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
Or if you prefer to go with NGINX mainline packages, like i did in order to get the very last version, run this command instead:
echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
Now the next thing that you would have to do would be to import an official NGINX signing key in order to let and help apt verify the authenticity of the packages that you want to install. No worries, it’s not hard to do that. All you have to do is run the command:
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Before you continue, please make sure you verify that you have the proper key. Run this command:
sudo apt-key fingerprint ABF5BD827BD9BF62
After running the command above you should be able to see the output that is showing the full fingerprint. It looks something like this:
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
uid [ unknown] nginx signing key <[email protected]>
At this point, all you have to do is update repo resources and refresh them then install NGINX again. You can do that with two short commands:
sudo apt update
sudo apt install nginx
So that’s all. I needed this today so I thought I would just document it here quickly to sometimes come back and remind myself how to do this.
0 Comments