Mastering Nginx

(Ron) #1

Installing NGINX and Third-Party Modules


[ 8 ]

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


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 RBAC
(Role-based access control), 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,


pre-compiled binaries.


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/6/$basearch/


gpgcheck=0


enabled=1

Free download pdf