Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
NGINX HTTP Server

You're reading from   NGINX HTTP Server Harness the power of NGINX with a series of detailed tutorials and real-life examples

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781835469873
Length 262 pages
Edition 5th Edition
Languages
Tools
Concepts
Arrow right icon
Authors (3):
Arrow left icon
Martin Bjerretoft Fjordvald Martin Bjerretoft Fjordvald
Author Profile Icon Martin Bjerretoft Fjordvald
Martin Bjerretoft Fjordvald
Gabriel Ouiran Gabriel Ouiran
Author Profile Icon Gabriel Ouiran
Gabriel Ouiran
Mr. Clement Nedelcu Mr. Clement Nedelcu
Author Profile Icon Mr. Clement Nedelcu
Mr. Clement Nedelcu
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Part 1:Begin with NGINX FREE CHAPTER
2. Chapter 1: Downloading and Installing NGINX 3. Chapter 2: Basic NGINX Configuration 4. Part 2: Dive into NGINX
5. Chapter 3: Exploring the HTTP Configuration 6. Chapter 4: Exploring Module Configuration in NGINX 7. Chapter 5: PHP and Python with NGINX 8. Chapter 6: NGINX as a Reverse Proxy 9. Part 3: NGINX in Action
10. Chapter 7: Introduction to Load Balancing and Optimization 11. Chapter 8: NGINX within a Cloud Infrastructure 12. Chapter 9: Fully Deploy, Manage, and Auto-Update NGINX with Ansible 13. Chapter 10: Case Studies 14. Chapter 11: Troubleshooting 15. Index 16. Other Books You May Enjoy

Installing NGINX via package managers

The quickest, and easiest, way to install NGINX is to simply use your OS-provided version. Most of the time, these are kept fairly updated; however, for some Linux distributions focusing on stability, you may only have older versions of NGINX available. Sometimes, your Linux distribution may provide multiple versions of NGINX with different compile flags.

In general, before embarking on a more complex journey, we should check whether we can use the easy solution. For Red Hat Linux-based operating systems, we need to enable the EPEL repo first and then do the same:

yum install epel-release
yum search nginx
yum info PACKAGE_NAME
yum install PACKAGE_NAME

For a Debian-based operating system, we first find the NGINX compiles available and then get the information for the one we want:

apt-cache search nginx
apt-cache show PACKAGE_NAME
apt install PACKAGE_NAME

If the version provided is current enough, then you’re ready to configure NGINX in the next chapter.

If the version provided by your distribution is too old, then NGINX provides packages for RHEL/CentOS distributions as well as Debian/Ubuntu distributions. We encourage you to visit the official NGINX website to make sure the version given by your distribution isn’t outdated.

NGINX-provided packages

To set up a yum repository for RHEL/CentOS, create a file named /etc/yum.repos.d/nginx.repo with the following contents:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1

Replace OS with rhel or centos, depending on the distribution used, and OSRELEASE with 8 or 9, for versions 8.x or 9.x, respectively. Afterward, NGINX can now be installed with yum:

yum install nginx

For Debian-based distributions, we need to first use their signing key to authenticate the package signatures. Download the following file first from http://nginx.org/keys/nginx_signing.key.

Then, run the following command:

sudo apt-key add nginx_signing.key

With the key added, we can now add the NGINX repository to sources.list found in /etc/apt/sources.list. For Debian, we add the following lines:

deb http://nginx.org/packages/debian/ codename nginx
deb-src http://nginx.org/packages/debian/ codename nginx

Here, codename is either trixie or bookworm, depending on your version of Debian. For Ubuntu, we use the following dependencies:

deb http://nginx.org/packages/ubuntu/ codename nginx
deb-src http://nginx.org/packages/ubuntu/ codename nginx

Here, codename is either noble, focal, or bionic, depending on your version of Ubuntu. Finally, we can install NGINX with the apt command:

apt update
apt install nginx

Now that we have learned how to install NGINX from repositories, let’s have a look at how we can compile it from the source and benefit from having custom modules that are not provided with the default NGINX.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image