10 Feb 2019
Nginx Installation on Ubuntu or CentOS/RHEL Server
Ubuntu
Nginx is available in the default Ubuntu repositories. Installation is straightforward:
$ sudo apt-get update && sudo apt-get install nginx
CentOS/RHEL
On CentOS/RHEL, enable either the official Nginx repository or the EPEL repository before installing.
Nginx repository
Create /etc/yum.repos.d/nginx.repo with:
$ vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
Replace OS with rhel or centos, and OSRELEASE with 5, 6, or 7 to match your
OS version.
EPEL repository
RHEL/CentOS 7:
$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
RHEL/CentOS 6 (64-bit):
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RHEL/CentOS 6 (32-bit):
$ rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Install Nginx
Once a repository is enabled:
$ yum install nginx
Start and enable it on boot:
$ systemctl start nginx
$ systemctl enable nginx