Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Install the Latest Version of Nginx on Ubuntu

A complete Ubuntu guide to installing Nginx from nginx.org, choosing Mainline or Stable, verifying the signing key, pinning APT, and confirming the running version.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For the newest upstream Nginx release, configure the official nginx.org repository before installing. Choose its Mainline stream for the current release line, or Stable for a slower, more conservative update path. Ubuntu’s built-in package is simpler and integrates cleanly with the operating system, but it may not be the newest upstream build. The procedure below verifies your Ubuntu release and CPU architecture, authenticates the repository key, pins nginx.org packages, installs Nginx, and confirms the exact version and local response.

Choose where your Nginx package will come from

“Latest” depends on the repository you select. Ubuntu publishes a distribution-maintained Nginx package on its own schedule. The official nginx.org repository publishes separate Stable and Mainline streams; Mainline is the current upstream release stream and is the natural choice when receiving the newest Nginx release matters.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Source Update behavior Best fit Trade-off
Ubuntu repository Follows Ubuntu’s packaging and maintenance cadence Servers where distribution integration and simple maintenance are the priority May lag behind the newest upstream Nginx version
nginx.org Stable Conservative upstream stream with a slower change rate Production systems that favor operational conservatism Does not provide every current upstream feature as soon as Mainline
nginx.org Mainline Current upstream release stream Readers who specifically want the latest Nginx release Changes arrive sooner, so compatibility testing is more important

The commands in this guide use the official repository. Install only one nginx.org stream at a time. A repository entry for Stable and another for Mainline can make APT choose versions in ways you did not intend.

Check Ubuntu and architecture support first

Open a shell and identify the Ubuntu codename that APT will use:

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
lsb_release -cs

At the time of this guide’s verification (2026-10-15), the nginx.org package page listed Ubuntu 22.04 jammy, Ubuntu 24.04 noble, and Ubuntu 26.04 resolute for both x86_64 and arm64. Confirm that your codename and architecture appear on the current package page before adding a source. If they are not listed, stop rather than substituting a different codename; an apparently successful installation can leave you with incompatible libraries or packages.

It is also sensible to see whether Nginx is already installed and which repository would supply it:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nginx -v
apt-cache policy nginx

If nginx -v reports that the command is not found, Nginx is not installed. If an existing installation is present, note its version and configuration before changing repositories. Installing from nginx.org can replace the package supplied by Ubuntu, and a major version change should be tested with your current configuration.

Install Nginx from the official repository

1. Install the prerequisites

Refresh APT metadata and install the tools needed to download and verify the signing key:

sudo apt update
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

ca-certificates enables certificate validation for HTTPS downloads, gnupg2 provides the key-import tools, lsb-release supplies the Ubuntu codename used in the repository line, and ubuntu-keyring provides Ubuntu’s archive-key material.

2. Import the Nginx signing key into a dedicated keyring

Download the key from the official Nginx key endpoint and convert it to the binary keyring format used by APT:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor 
  | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

The signed-by setting you will add later limits this repository to the key in this file instead of trusting every key installed globally on the machine.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

3. Verify the key fingerprints before trusting the repository

Inspect the keyring without importing it into your personal key database:

gpg --dry-run --quiet --no-keyring --import --import-options import-show 
  /usr/share/keyrings/nginx-archive-keyring.gpg

The output should contain the complete fingerprints published by NGINX:

  • 8540A6F18833A80E9C1653A42FD21310B49F6B46
  • 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
  • 9E9BE90EACBCDE69FE9B204CBCDCD8A38D88A2B3

If the fingerprints do not match exactly, remove the downloaded key and stop:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo rm /usr/share/keyrings/nginx-archive-keyring.gpg

Do not continue with an unverified key. The legacy Nginx signing key is currently published with an expiry date of 2027-05-24, so key maintenance remains relevant even after a successful installation.

4. Add exactly one nginx.org repository stream

Use the Stable entry when you want the conservative stream:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] 
  https://nginx.org/packages/ubuntu `lsb_release -cs` nginx" 
  | sudo tee /etc/apt/sources.list.d/nginx.list

Use the Mainline entry when “latest” means the current upstream release stream:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] 
  https://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" 
  | sudo tee /etc/apt/sources.list.d/nginx.list

Both commands write the same file, so run only the one that matches your decision. The backtick expression inserts the codename returned by lsb_release -cs. You can inspect the resulting line with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
cat /etc/apt/sources.list.d/nginx.list

It should show your actual Ubuntu codename and the expected repository path. If you previously created another Nginx source file, remove or disable it before continuing so APT is not combining streams.

5. Pin nginx.org packages so APT prefers them

Create an APT preference with a priority of 900 for packages whose origin is nginx.org:

echo -e "Package: *nPin: origin nginx.orgnPin: release o=nginxnPin-Priority: 900n" 
  | sudo tee /etc/apt/preferences.d/99nginx

This preference does not bypass signature verification. The repository still has to authenticate with the key specified by signed-by; pinning only resolves which repository APT prefers when multiple sources offer a package.

6. Refresh metadata and install Nginx

sudo apt update
sudo apt install nginx

Read the APT transaction before accepting it. Check that the candidate package is coming from the nginx.org stream you selected rather than an unexpected Ubuntu or third-party source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

7. Start Nginx and verify the local server

Start the web server directly, then send a request to the loopback address:

sudo nginx
curl -I 127.0.0.1

A working installation should return HTTP headers; the NGINX documentation example returns HTTP/1.1 200 OK. A loopback request tests the local listener without depending on DNS, firewall rules, a public IP address, or an external load balancer.

8. Check the exact installed version

sudo nginx -v

The command prints the version of the executable actually installed. NGINX documentation displayed nginx/1.31.7 in its example at the 2026-10-15 verification date, but that is not a promise about your machine: repository metadata changes as new packages are published. Treat your command output and current APT metadata as authoritative.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Use Ubuntu’s package instead when simplicity is the priority

Ubuntu’s server documentation provides this shorter path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update && sudo apt install nginx

Ubuntu states that the command installs the required dependencies and starts the web server. This option avoids managing a separate repository key, source file, and pin. It is a reasonable choice for a server that must follow Ubuntu’s integrated update and support model, or when the exact newest upstream release is not a requirement.

After installation, verify the result in the same way:

curl -I 127.0.0.1
sudo nginx -v

If the printed version is older than the current nginx.org package, that is an expected consequence of choosing Ubuntu’s packaging cadence rather than evidence that the installation failed.

Stable versus Mainline: which stream should you select?

Decision factor Stable Mainline
Release position Conservative upstream stream Current upstream release stream
Change rate Slower change rate New changes arrive sooner
Feature timing Features reach this stream later Newest upstream features are available first
Operational profile Useful when minimizing change is more important than immediacy Useful when obtaining the latest release is the primary goal
Before switching Review the NGINX changelog and test compatibility with your configuration, modules, operating system, and application stack

Mainline is not a synonym for an untested nightly build; it is Nginx’s current release stream. Stable is not frozen forever; it continues to receive its own updates. The practical distinction is how quickly changes reach you and how much compatibility testing your operations process requires.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Know the files you will edit and monitor

The primary configuration file is:

/etc/nginx/nginx.conf

The default log files are:

  • /var/log/nginx/access.log records requests handled by the server.
  • /var/log/nginx/error.log records errors and diagnostic messages.

Keep a copy of the working configuration before making substantial edits. When a request fails, inspect the error log first; it can distinguish a syntax or permission problem from an application that is returning an error after Nginx successfully accepted the connection.

Optional dynamic modules, when available for your chosen package stream, use package names in the form nginx-module-<NAME>. Install a module built for the same repository stream and version family as the core Nginx package; mixing packages from unrelated sources can create dependency or ABI problems.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Verify repository selection and diagnose common failures

APT still selects Ubuntu’s older package

Inspect the candidate and all available versions:

apt-cache policy nginx

Check that /etc/apt/sources.list.d/nginx.list contains the intended nginx.org path and codename, and that /etc/apt/preferences.d/99nginx contains the priority 900 rule. Run sudo apt update again after correcting either file.

APT reports a signature or “NO_PUBKEY” error

Confirm that the key file exists at /usr/share/keyrings/nginx-archive-keyring.gpg, that the repository line uses the identical signed-by path, and that the fingerprints match all three published values. If the fingerprints are wrong, delete the key, download it again, and verify it before running APT.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The repository returns a codename or architecture error

Re-run lsb_release -cs and compare the result with the Ubuntu releases and architectures currently listed on the nginx.org package page. Do not point a release at a different codename merely to make APT proceed. Upgrade Ubuntu to a supported release or use Ubuntu’s own package until the desired release is supported.

curl -I 127.0.0.1 cannot connect

Check whether the Nginx process was started with sudo nginx. Then inspect /var/log/nginx/error.log for a startup error. A failed configuration, an occupied listening port, or insufficient permissions can prevent a listener from appearing even though package installation completed.

The version is not the one you expected

Run sudo nginx -v and apt-cache policy nginx together. The first reports the binary in use; the second shows which repository APT considers the candidate. If you changed from Stable to Mainline, ensure only the intended source remains in /etc/apt/sources.list.d/nginx.list, refresh metadata, and review the proposed transaction before upgrading.

Switching streams safely

Switching from Stable to Mainline, or the reverse, is a repository change rather than a new installation procedure. Back up /etc/nginx/nginx.conf and any included configuration, review the NGINX changelog and module compatibility, replace the repository line with the desired stream, run sudo apt update, and inspect apt-cache policy nginx before accepting an upgrade. Keep the existing keyring and pin file unless you are deliberately changing repository policy. After the package operation, run sudo nginx -v and curl -I 127.0.0.1 again.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Installation checklist

  • Your Ubuntu codename and x86_64 or arm64 architecture are listed as supported by the current nginx.org package page.
  • Prerequisites are installed with sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring.
  • The signing key is stored at /usr/share/keyrings/nginx-archive-keyring.gpg and its three fingerprints match exactly.
  • Only one nginx.org stream is present in /etc/apt/sources.list.d/nginx.list.
  • APT pinning gives origin nginx.org a priority of 900.
  • sudo apt update completes without signature or release-file errors.
  • sudo nginx -v reports the expected installed version.
  • curl -I 127.0.0.1 returns HTTP headers, normally including a successful status such as HTTP/1.1 200 OK.
  • You know where the main configuration and access and error logs are before changing the server.

Frequently Asked Questions

Does installing from nginx.org automatically mean I have the newest possible version?

It gives you the newest package available in the stream and repository metadata you selected. Mainline is the current upstream stream; the exact version still changes as Nginx publishes updates, so check sudo nginx -v after installation.

Can Stable and Mainline repositories be enabled at the same time?

They should not be mixed for a normal installation. Keep one nginx.org stream in /etc/apt/sources.list.d/nginx.list, then refresh APT and inspect apt-cache policy nginx before upgrading.

Where should I look when Nginx starts but requests fail?

Start with /var/log/nginx/error.log, then review /var/log/nginx/access.log for the request. These files can show whether the failure occurs while Nginx is accepting the connection or while it is processing the request.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.