Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering NGINX

You're reading from   Mastering NGINX Personalize, customize and configure NGINX to meet the needs of your server

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher
ISBN-13 9781782173311
Length 320 pages
Edition 2nd Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Dimitri Aivaliotis Dimitri Aivaliotis
Author Profile Icon Dimitri Aivaliotis
Dimitri Aivaliotis
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Installing NGINX and Third-Party Modules FREE CHAPTER 2. A Configuration Guide 3. Using the mail Module 4. NGINX as a Reverse Proxy 5. Reverse Proxy Advanced Topics 6. The NGINX HTTP Server 7. NGINX for the Application Developer 8. Integrating Lua with NGINX 9. Troubleshooting Techniques A. Directive Reference
B. The Rewrite Rule Guide C. The NGINX Community D. Persisting Solaris Network Tunings
Index

Installing NGINX using a package manager

Chances are that your operating system of choice already provides nginx as a package. Installing it is as simple as using your package manager's commands:

  • Linux (deb-based)
    sudo apt-get install nginx
    
  • Linux (rpm-based)
    sudo yum install nginx
    
  • FreeBSD
    sudo pkg_install -r nginx
    

Note

The sudo command is representative of what you need to execute on your operating system to achieve superuser (root) privileges. If your operating system supports role-based access control (RBAC), then you would use a different command, such as pfexec, to achieve the same goal.

These commands will install NGINX into standard locations, specific to your operating system. This is the preferred installation method if you need to use your operating system's packages.

The NGINX core team also provides binaries of the stable version, available from http://nginx.org/en/download.html. Users of distributions without an nginx package (such as CentOS) can use the following instructions to install pre-tested and pre-compiled binaries.

Installing NGINX on CentOS

Add the NGINX repository to your yum configuration by creating the following file:

sudo vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

Then install nginx by executing the following command:

sudo yum install nginx

Alternative instructions for installing an nginx-release package are available at the preceding URL.

Installing NGINX on Debian

Let's install NGINX on Debian using the following steps:

  1. Install the NGINX signing key by downloading it from http://nginx.org/keys/nginx_signing.key and adding it to the apt keyring:
    sudo apt-key add nginx_signing.key
    
  2. Append the nginx.org repository to the end of /etc/apt/sources.list:
    vi /etc/apt/sources.list
    deb http://nginx.org/packages/debian/ jessie nginx
    deb-src http://nginx.org/packages/debian/ jessie nginx
  3. Then install nginx by executing the following command:
    sudo apt-get update
    sudo apt-get install nginx
    

If your operating system does not include nginx in its list of available packages, the version is too old for what you would like to do, the packages at nginx.org don't serve your needs, you would like to use the development release of NGINX, or if you want to enable/disable specific modules, then compiling NGINX from source is the only other option.

You have been reading a chapter from
Mastering NGINX - Second Edition
Published in: Jul 2016
Publisher:
ISBN-13: 9781782173311
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