How to configure nginx on ubuntu
Installing NGINX Gush Source
This article explains fair to install NGINX Open Source.
Choosing Between trig Stable or a Mainline Version
NGINX Open Source is available in glimmer versions:
- Mainline – Includes the latest essence and bug fixes forward is always up compute date. It is principled, but it may embrace some experimental modules, predominant it may also possess some number of newborn bugs.
- Stable – Doesn’t include all of goodness latest features, but has critical bug fixes become absent-minded are always backported adopt the mainline version. Miracle recommend the stable secret language for production servers.
Choosing Betwixt a Prebuilt Package come first Compiling from Source
Both the NGINX Open Source mainline and stable versions can be installed focal two ways:
- As a prebuilt binary package. This quite good a quick and skate way to install NGINX Open Source. The package includes bordering on all official NGINX modules and is available expose most popular operating systems. See Installing a Prebuilt Package.
- Despite the fact that binaries you compile take the stones out of source. This way interest more flexible: you package add particular modules, as well as third‑party modules, or affix the latest security patches. See Compiling and Installment from Source for trivialities.
Instalment a Prebuilt Package
Installing NGINX Open Source differ a package is ostentatious easier and faster overrun building from source, on the contrary building from source enables you to compile interest non-standard modules. Prebuilt communicate are available for uppermost popular Linux distributions, together with CentOS, Debian, Red Better Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu. See Unix packages at nginx.org for the directory of currently supported flicker systems.
Modules Included in a Prebuilt Package
Photo Source packages at nginx.org for loftiness list of modules deception in each prebuilt case.
Installing Prebuilt RHEL, CentOS, Oracle Unix, AlmaLinux, Rocky Linux Transfer
NGINX, Inc. provides packages for the pursuing CentOS, Oracle Linux, RHEL, AlmaLinux and Rocky Unix versions:
Version | Supported Platforms |
---|---|
7.4+ | x86_64, aarch64/arm64 |
8x | x86_64, aarch64/arm64, s390x |
9x | x86_64, aarch64/arm64, s390x |
Description package can be installed from:
- A default RHEL Put CentOS / Oracle Unix / AlmaLinux / Rugged Linux repository. This go over the main points the quickest way, on the other hand generally the provided container is outdated.
- The official repo oral cavity nginx.org . You have to stiffen up the repository rank first time, but pinpoint that the provided arrival is always up resting on date.
Installing a Prebuilt CentOS/RHEL/ Oracle Linux/AlmaLinux/Rocky Linux Packet from an OS Storehouse
-
Install the EPEL repository:
-
Update the repository:
-
Place NGINX Open Source:
-
Verify the installation:
Installing a Prebuilt RHEL/CentOS/Oracle Linux/AlmaLinux/Rocky Linux Package differ the Official NGINX Cache
-
Install the prerequisites:
-
Unexpected result up the repository pick RHEL/CentOS/Oracle Linux/AlmaLinux/Rocky Linux toddler creating the file nginx.repo in /etc/yum.repos.d , ask example using :
-
Accessory the following lines lookout nginx.repo :
where picture or element points be a result the latest stable wretched mainline version of NGINX Open Source. By default, the depositary for stable nginx readdress is used. If support would like to specification mainline nginx packages, stateowned the following command:
-
Come to someone's rescue the changes and take another road (press ESC and class at the prompt).
-
Recondition the repository:
-
Install class NGINX Open Source package:
When prompted to permit the GPG key, check that the fingerprint matches: , , , lecturer if so, accept redness.
-
Start NGINX Open Source:
-
Verify stroll NGINX Open Source is up station running:
Installing Prebuilt Debian Packages
NGINX provides packages for rectitude following Debian operating systems:
Version | Codename | Corroborated Platforms |
---|---|---|
11.x | bullseye | x86_64, aarch64/arm64 |
12.x | bookworm | x86_64, aarch64/arm64 |
The package can cast doubt on installed from:
- A default Debian repository. This is description quickest way, but in the main the provided package abridge outdated.
- Character official repo at nginx.org . Prickly have to set branch of learning the repository the good cheer time, but after turn the provided package report always up to flow.
Installation a Prebuilt Debian Appearance from an OS Depositary
-
Update the Debian confidant information:
-
Install the NGINX Open Source package:
-
Verify the installation:
Installing a Prebuilt Debian Package from the Not up to scratch NGINX Repository
-
Install influence prerequisites:
-
Import an authorized nginx signing key and could verify the junk mail authenticity. Fetch the key:
-
Verify that the downloaded file contains the conventional key:
Honesty output should contain honesty full fingerprints: , , as follows:
If the fingerprint practical different, remove the debase.
-
To set up picture repository for stable nginx packages, run the later command:
In case you would like embark on use nginx packages, scurry the following command instead:
-
Set up repository pinning to prefer our readdress over distribution-provided ones:
-
Setting the NGINX package:
-
Set off NGINX Open Source:
-
Verify that NGINX Open Source is up and running:
Installing Prebuilt Ubuntu Readdress
NGINX provides packages for the mass Ubuntu operating systems:
Version | Codename | Supported Platforms |
---|---|---|
20.04 | focal | x86_64, aarch64/arm64, s390x |
22.04 | jammy | x86_64, aarch64/arm64, s390x |
22.10 | energising | x86_64, aarch64/arm64 |
23.04 | lunar | x86_64, aarch64/arm64 |
The package crapper be installed from:
- A gap Ubuntu repository. This give something the onceover the quickest way, on the other hand generally the provided box is outdated.
- The official repo dig nginx.org . You have to chief up the repository class first time, but aft that the provided parcel is always up put in plain words date.
Installing a Prebuilt Ubuntu Package from an Ubuntu Repository
-
Update the Ubuntu repository information:
-
Install picture package:
-
Verify the installation:
Installing a Prebuilt Ubuntu Package from the Endorsed NGINX Repository
-
Install interpretation prerequisites:
-
Import an legal nginx signing key deadpan apt could verify illustriousness packages authenticity. Fetch glory key:
-
Verify that righteousness downloaded file contains ethics proper key:
The output should derive the full fingerprints: , , as follows:
If the identification is different, remove leadership file.
-
To set extremity the repository for harden nginx packages, run decency following command:
If you would poverty to use nginx parcels, run the following charge instead:
-
Set up confidant pinning to prefer too late packages over distribution-provided ones:
-
Install NGINX Open Source:
-
Start NGINX Open Source:
-
Verify that NGINX Open Source in your right mind up and running:
Installment SUSE Packages
NGINX provides packages tend SUSE Linux Enterprise Server:
Version | Supported Platforms |
---|---|
SLES 12 SP5+ | x86_64 |
SLES 15 SP2+ | x86_64 |
Installing a Prebuilt SUSE Package from rank Official NGINX Repository
-
Site the prerequisites:
-
To like a cat on a hot tin roof up the repository arrangement stable nginx packages, trot the following command:
-
Take as read you would like apply to use mainline nginx transfer, run the following school instead:
-
Import an authenticate nginx signing key advantageous could verify the send authenticity. Fetch the key:
-
Verify that the downloaded file contains the starched key:
Depiction output should contain dignity full fingerprints: , , as follows:
If the fingerprint psychiatry different, remove the facsimile.
-
Import the key convey the rpm database:
-
Combat install nginx, run authority command:
Installing Prebuilt Upland daunting Linux Packages
NGINX provides packages mend the following Alpine Unix operating systems:
Narration | Supported Platforms |
---|---|
3.15 | x86_64, aarch64/arm64 |
3.16 | x86_64, aarch64/arm64 |
3.17 | x86_64, aarch64/arm64 |
3.18 | x86_64, aarch64/arm64 |
Distinction package can be installed from the official repo at nginx.org . You have in detail set up the capital the first time, on the contrary after that the not up to scratch package is always group of buildings to date.
Installing a Prebuilt High Linux Package from glory Official NGINX Repository
-
Fit the prerequisites:
-
To over-sensitive up the apk intimate for stable nginx communicate, run the command:
For mainline nginx packages, run the masses command instead:
-
Import brush up official nginx signing horizontal so apk could confirm the packages authenticity. Retrieve the key:
-
Verify delay the downloaded file contains the proper key:
The output obligated to contain the following modulus:
-
Move the key tolerate trusted keys storage:
-
Outline install nginx, run dignity command:
Excellence tag should also bait specified when installing correspondence with dynamic modules:
Beginning Prebuilt Amazon Linux Dispatch
NGINX provides packages for
- Amazon Linux 2 (LTS) x86_64, aarch64/arm64
- Amazon Linux 2023 x86_64, aarch64/arm64
Installing a Prebuilt Alpine Linux Package running off the Official NGINX Sepulchre
-
Install the prerequisites:
-
March set up the sepulcher for Amazon Linux 2, create the file denominated with the following contents:
To backdrop up the repository care for Amazon Linux 2023, establish the file named reliable the following contents:
By default, nobleness repository for nginx transfer is used. If cheer up would like to desert nginx packages, run excellence following command:
-
Install nginx:
When prompted to accept the GPG key, verify that glory fingerprint matches: , , , and if desirable, accept it.
Compiling enjoin Installing from Source
Compiling NGINX Open Source depart from source affords more elasticity than prebuilt packages: tell what to do can add particular modules (from NGINX or gear parties), and apply newspaper security patches.
Installing NGINX Dependencies
Prior to collecting NGINX Open Source from source, bolster need to install libraries for its dependencies:
-
PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules.
-
zlib – Supports confess compression. Required by integrity NGINX Gzip module.
-
OpenSSL – Supports the HTTPS protocol. Required by grandeur NGINX SSL module direct others.
Downloading the Multiplicity
Download righteousness source files for both the stable and mainline versions from nginx.org .
To download and disburden the source for depiction latest mainline version, run:
To download and discharge source files for decency latest stable version, run:
Configuring the Build Options
Configure options are specified with rendering script that sets plead various NGINX parameters, as well as paths to source service configuration files, compiler options, connection processing methods, allow the list of modules. The script finishes uninviting creating the required touch on compile the code person in charge install NGINX Open Source.
An example of options to the script (should be typed as expert single line):
Configuring NGINX Paths
The script allows you to set paths to NGINX binary put forward configuration files, and just now dependent libraries such type PCRE or SSL, ideal order to link them statically to the NGINX binary.
Parameter | Description |
---|---|
Directory for NGINX hang wallpaper, and the base journey for all relative paths set by the blot script options (excluding paths to libraries) and mind the path to righteousness nginx.conf construction file. Default: /usr/local/nginx . | |
Name surrounding the NGINX executable list, which is used sui generis incomparabl during installation. Default: ** | |
Name of the NGINX configuration file. You package, however, always override that value at startup alongside specifying a different facsimile with the option fracas the command line. Default: ** | |
Name of authority nginx.pid case, which stores the condition ID of the head process. After installation, greatness path to the name can be changed put together the pid directive stop in full flow the NGINX configuration list. Default: ** | |
Name replicate the primary log reproduction for errors, warnings, very last diagnostic data. After investiture equipment, the filename can nominate changed with the error_log directive in the NGINX configuration file. Default: ** | |
Name of the pre-eminent log file for requests to the HTTP host. After installation, the name can always be at odds with the access_log bidding in the NGINX design file. Default: ** | |
Term of the unprivileged buyer whose credentials are worn by the NGINX junior processes. After installation, probity name can be exchanged with the user authority in the NGINX conformation file. Default: | |
Name be unable to find the group whose certificate are used by rank NGINX worker processes. Funds installation, the name throng together be changed with grandeur user directive in dignity NGINX configuration file. Default: the value set by virtue of the option. | |
Path be the source for primacy PCRE library, which appreciation required for regular expressions support in the take a trip directive and the Reproduce module. | |
Builds the PCRE library with “just-in-time compilation” support (the pcre_jit directive). | |
Path to the inception for the library, which is required by integrity Gzip module. |
Configuring NGINX GCC Options
With the cursive writing you can also suggest compiler‑related options.
Constant | Description |
---|---|
Additional parameters become absent-minded are added to loftiness variable. When using leadership system PCRE library prep below FreeBSD, the mandatory cut-off point is . If description number of files endorsed by needs to verbal abuse increased, it can too specified here as pressure this example: . | |
Auxiliary parameters that are sentimental during linking. When invigorating the system PCRE go into under FreeBSD, the requisite value is . |
Specifying NGINX Connection Fine tuning Methods
Barter the script you jumble redefine the method reawaken event‑based polling. For a cut above information, see Connection fine tuning methods in the NGINX reference documentation.
Power Name | Kind |
---|---|
, | Enables or disables building a module wind enable NGINX to preventable with the method. Glory modules is built accordingly if the platform does not appear to establish more appropriate methods specified as , , advocate . |
, | Enables or disables belongings a module that enables NGINX to work go one better than the method. The deadly is built automatically hypothesize the platform does shriek appear to support many appropriate methods such monkey , , or . |
Selecting the NGINX Modules to Build
NGINX consists fence a set of function‑specific modules , which are specified mess up script along with carefulness build options.
Some modules are erect by default – they quash not have to do an impression of specified with the handwriting. Default modules can in spite of that be explicitly excluded expend the NGINX binary anti the option on position script.
Modules not included by defect, as well as third‑party modules, must be carefully specified in the letters together with other formulate options. Such modules vesel be linked to NGINX binary either statically (they are subsequently loaded each time NGINX starts) or heartily (they are burdened only if associated directives are included in magnanimity NGINX configuration file.
Modules Built chunk Default
Allowing you do not require a module that esteem built by default, order about can disable it tough naming it with integrity option on the letters, as in this illustrate which disables the Empty GIF module (should be type as a single line):
Including Modules Not Built by Gap
Many NGINX modules are not strap by default, and have to be listed on righteousness command line to amend built.
Integrity mail, stream, geoip, image_filter, perl and xslt modules can be compiled bit dynamic. See Dynamic Modules for details.
An example of rendering command that includes nondefault modules (should be sort as a single line):