How To Install Nginx on CentOS 8


Step 1: Add Nginx Repository

sudo yum install epel-release

Result:

[root@tutorialspots ~]# sudo yum install epel-release
CentOS-8 - AppStream                             21 MB/s | 5.8 MB     00:00
CentOS-8 - Base                                  14 MB/s | 2.2 MB     00:00
CentOS-8 - Extras                                73 kB/s | 6.7 kB     00:00
Extra Packages for Enterprise Linux Modular 8 - 310 kB/s | 154 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64   12 MB/s | 7.2 MB     00:00
Package epel-release-8-8.el8.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

Step 2: Install Nginx

sudo yum install nginx

Result:

[root@tutorialspots ~]# sudo yum install nginx
Last metadata expiration check: 0:01:04 ago on Wed 08 Jul 2020 06:13:04 AM CEST.
Dependencies resolved.
================================================================================
 Package                     Arch   Version                     Repo       Size
================================================================================
Installing:
 nginx                       x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream 570 k
Installing dependencies:
 dejavu-fonts-common         noarch 2.35-6.el8                  BaseOS     74 k
 dejavu-sans-fonts           noarch 2.35-6.el8                  BaseOS    1.5 M
 fontconfig                  x86_64 2.13.1-3.el8                BaseOS    275 k
 fontpackages-filesystem     noarch 1.44-22.el8                 BaseOS     16 k
 gd                          x86_64 2.2.5-6.el8                 AppStream 144 k
 jbigkit-libs                x86_64 2.1-14.el8                  AppStream  55 k
 libX11                      x86_64 1.6.8-3.el8                 AppStream 611 k
 libX11-common               noarch 1.6.8-3.el8                 AppStream 158 k
 libXau                      x86_64 1.0.8-13.el8                AppStream  36 k
 libXpm                      x86_64 3.5.12-8.el8                AppStream  58 k
 libjpeg-turbo               x86_64 1.5.3-10.el8                AppStream 156 k
 libtiff                     x86_64 4.0.9-17.el8                AppStream 188 k
 libwebp                     x86_64 1.0.0-1.el8                 AppStream 273 k
 libxcb                      x86_64 1.13.1-1.el8                AppStream 229 k
 libxslt                     x86_64 1.1.32-4.el8                BaseOS    249 k
 nginx-all-modules           noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  23 k
 nginx-filesystem            noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  24 k
 nginx-mod-http-image-filter x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  35 k
 nginx-mod-http-perl         x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  45 k
 nginx-mod-http-xslt-filter  x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  33 k
 nginx-mod-mail              x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  64 k
 nginx-mod-stream            x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82
                                                                AppStream  85 k
 perl-Carp                   noarch 1.42-396.el8                BaseOS     30 k
 perl-Errno                  x86_64 1.28-416.el8                BaseOS     76 k
 perl-Exporter               noarch 5.72-396.el8                BaseOS     34 k
 perl-File-Path              noarch 2.15-2.el8                  BaseOS     38 k
 perl-IO                     x86_64 1.38-416.el8                BaseOS    141 k
 perl-PathTools              x86_64 3.74-1.el8                  BaseOS     90 k
 perl-Scalar-List-Utils      x86_64 3:1.49-2.el8                BaseOS     68 k
 perl-Socket                 x86_64 4:2.027-3.el8               BaseOS     59 k
 perl-Text-Tabs+Wrap         noarch 2013.0523-395.el8           BaseOS     24 k
 perl-Unicode-Normalize      x86_64 1.25-396.el8                BaseOS     82 k
 perl-constant               noarch 1.33-396.el8                BaseOS     25 k
 perl-interpreter            x86_64 4:5.26.3-416.el8            BaseOS    6.3 M
 perl-libs                   x86_64 4:5.26.3-416.el8            BaseOS    1.6 M
 perl-macros                 x86_64 4:5.26.3-416.el8            BaseOS     72 k
 perl-parent                 noarch 1:0.237-1.el8               BaseOS     20 k
 perl-threads                x86_64 1:2.21-2.el8                BaseOS     61 k
 perl-threads-shared         x86_64 1.58-2.el8                  BaseOS     48 k
Enabling module streams:
 nginx                              1.14

Transaction Summary
================================================================================
Install  40 Packages

Total download size: 14 M
Installed size: 36 M
Is this ok [y/N]: y
Downloading Packages:
(1/40): jbigkit-libs-2.1-14.el8.x86_64.rpm      884 kB/s |  55 kB     00:00
(2/40): gd-2.2.5-6.el8.x86_64.rpm               1.8 MB/s | 144 kB     00:00
(3/40): libXau-1.0.8-13.el8.x86_64.rpm          2.2 MB/s |  36 kB     00:00
(4/40): libX11-common-1.6.8-3.el8.noarch.rpm    4.7 MB/s | 158 kB     00:00
(5/40): libX11-1.6.8-3.el8.x86_64.rpm           5.4 MB/s | 611 kB     00:00
(6/40): libXpm-3.5.12-8.el8.x86_64.rpm          3.2 MB/s |  58 kB     00:00
(7/40): libjpeg-turbo-1.5.3-10.el8.x86_64.rpm   8.5 MB/s | 156 kB     00:00
(8/40): libtiff-4.0.9-17.el8.x86_64.rpm          10 MB/s | 188 kB     00:00
(9/40): libxcb-1.13.1-1.el8.x86_64.rpm           12 MB/s | 229 kB     00:00
(10/40): libwebp-1.0.0-1.el8.x86_64.rpm         7.8 MB/s | 273 kB     00:00
(11/40): nginx-all-modules-1.14.1-9.module_el8. 1.4 MB/s |  23 kB     00:00
(12/40): nginx-1.14.1-9.module_el8.0.0+184+e34f  14 MB/s | 570 kB     00:00
(13/40): nginx-filesystem-1.14.1-9.module_el8.0 1.0 MB/s |  24 kB     00:00
(14/40): nginx-mod-http-perl-1.14.1-9.module_el 2.7 MB/s |  45 kB     00:00
(15/40): nginx-mod-http-image-filter-1.14.1-9.m 923 kB/s |  35 kB     00:00
(16/40): nginx-mod-http-xslt-filter-1.14.1-9.mo 1.2 MB/s |  33 kB     00:00
(17/40): nginx-mod-stream-1.14.1-9.module_el8.0 1.8 MB/s |  85 kB     00:00
(18/40): dejavu-fonts-common-2.35-6.el8.noarch. 1.2 MB/s |  74 kB     00:00
(19/40): nginx-mod-mail-1.14.1-9.module_el8.0.0 876 kB/s |  64 kB     00:00
(20/40): fontpackages-filesystem-1.44-22.el8.no 247 kB/s |  16 kB     00:00
(21/40): fontconfig-2.13.1-3.el8.x86_64.rpm     3.8 MB/s | 275 kB     00:00
(22/40): perl-Carp-1.42-396.el8.noarch.rpm      2.5 MB/s |  30 kB     00:00
(23/40): perl-Errno-1.28-416.el8.x86_64.rpm     5.5 MB/s |  76 kB     00:00
(24/40): perl-Exporter-5.72-396.el8.noarch.rpm  2.5 MB/s |  34 kB     00:00
(25/40): dejavu-sans-fonts-2.35-6.el8.noarch.rp  10 MB/s | 1.5 MB     00:00
(26/40): perl-File-Path-2.15-2.el8.noarch.rpm   2.8 MB/s |  38 kB     00:00
(27/40): libxslt-1.1.32-4.el8.x86_64.rpm        4.1 MB/s | 249 kB     00:00
(28/40): perl-IO-1.38-416.el8.x86_64.rpm         10 MB/s | 141 kB     00:00
(29/40): perl-PathTools-3.74-1.el8.x86_64.rpm   6.3 MB/s |  90 kB     00:00
(30/40): perl-Scalar-List-Utils-1.49-2.el8.x86_ 5.3 MB/s |  68 kB     00:00
(31/40): perl-Socket-2.027-3.el8.x86_64.rpm     4.6 MB/s |  59 kB     00:00
(32/40): perl-Text-Tabs+Wrap-2013.0523-395.el8. 2.0 MB/s |  24 kB     00:00
(33/40): perl-Unicode-Normalize-1.25-396.el8.x8 6.3 MB/s |  82 kB     00:00
(34/40): perl-constant-1.33-396.el8.noarch.rpm  2.1 MB/s |  25 kB     00:00
(35/40): perl-macros-5.26.3-416.el8.x86_64.rpm  5.0 MB/s |  72 kB     00:00
(36/40): perl-parent-0.237-1.el8.noarch.rpm     1.5 MB/s |  20 kB     00:00
(37/40): perl-threads-2.21-2.el8.x86_64.rpm     3.8 MB/s |  61 kB     00:00
(38/40): perl-libs-5.26.3-416.el8.x86_64.rpm     26 MB/s | 1.6 MB     00:00
(39/40): perl-threads-shared-1.58-2.el8.x86_64. 3.7 MB/s |  48 kB     00:00
(40/40): perl-interpreter-5.26.3-416.el8.x86_64  51 MB/s | 6.3 MB     00:00
--------------------------------------------------------------------------------
Total                                            23 MB/s |  14 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : perl-Exporter-5.72-396.el8.noarch                     1/40
  Installing       : perl-libs-4:5.26.3-416.el8.x86_64                     2/40
  Installing       : perl-Carp-1.42-396.el8.noarch                         3/40
  Installing       : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64            4/40
  Installing       : fontpackages-filesystem-1.44-22.el8.noarch            5/40
  Installing       : libjpeg-turbo-1.5.3-10.el8.x86_64                     6/40
  Installing       : dejavu-fonts-common-2.35-6.el8.noarch                 7/40
  Installing       : dejavu-sans-fonts-2.35-6.el8.noarch                   8/40
  Installing       : fontconfig-2.13.1-3.el8.x86_64                        9/40
  Running scriptlet: fontconfig-2.13.1-3.el8.x86_64                        9/40
  Installing       : perl-macros-4:5.26.3-416.el8.x86_64                  10/40
  Installing       : perl-parent-1:0.237-1.el8.noarch                     11/40
  Installing       : perl-Errno-1.28-416.el8.x86_64                       12/40
  Installing       : perl-Socket-4:2.027-3.el8.x86_64                     13/40
  Installing       : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch         14/40
  Installing       : perl-Unicode-Normalize-1.25-396.el8.x86_64           15/40
  Installing       : perl-File-Path-2.15-2.el8.noarch                     16/40
  Installing       : perl-IO-1.38-416.el8.x86_64                          17/40
  Installing       : perl-PathTools-3.74-1.el8.x86_64                     18/40
  Installing       : perl-constant-1.33-396.el8.noarch                    19/40
  Installing       : perl-threads-1:2.21-2.el8.x86_64                     20/40
  Installing       : perl-threads-shared-1.58-2.el8.x86_64                21/40
  Installing       : perl-interpreter-4:5.26.3-416.el8.x86_64             22/40
  Installing       : libxslt-1.1.32-4.el8.x86_64                          23/40
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34   24/40
  Installing       : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34   24/40
  Installing       : libwebp-1.0.0-1.el8.x86_64                           25/40
  Installing       : libXau-1.0.8-13.el8.x86_64                           26/40
  Installing       : libxcb-1.13.1-1.el8.x86_64                           27/40
  Installing       : libX11-common-1.6.8-3.el8.noarch                     28/40
  Installing       : libX11-1.6.8-3.el8.x86_64                            29/40
  Installing       : libXpm-3.5.12-8.el8.x86_64                           30/40
  Installing       : jbigkit-libs-2.1-14.el8.x86_64                       31/40
  Running scriptlet: jbigkit-libs-2.1-14.el8.x86_64                       31/40
  Installing       : libtiff-4.0.9-17.el8.x86_64                          32/40
  Installing       : gd-2.2.5-6.el8.x86_64                                33/40
  Running scriptlet: gd-2.2.5-6.el8.x86_64                                33/40
  Installing       : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+   34/40
  Running scriptlet: nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+   34/40
  Installing       : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0   35/40
  Running scriptlet: nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0   35/40
  Installing       : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fe   36/40
  Running scriptlet: nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fe   36/40
  Installing       : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34   37/40
  Running scriptlet: nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34   37/40
  Installing       : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_6   38/40
  Running scriptlet: nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_6   38/40
  Installing       : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.   39/40
  Running scriptlet: nginx-mod-http-image-filter-1:1.14.1-9.module_el8.   39/40
  Installing       : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e3   40/40
  Running scriptlet: nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e3   40/40
  Running scriptlet: fontconfig-2.13.1-3.el8.x86_64                       40/40
  Verifying        : gd-2.2.5-6.el8.x86_64                                 1/40
  Verifying        : jbigkit-libs-2.1-14.el8.x86_64                        2/40
  Verifying        : libX11-1.6.8-3.el8.x86_64                             3/40
  Verifying        : libX11-common-1.6.8-3.el8.noarch                      4/40
  Verifying        : libXau-1.0.8-13.el8.x86_64                            5/40
  Verifying        : libXpm-3.5.12-8.el8.x86_64                            6/40
  Verifying        : libjpeg-turbo-1.5.3-10.el8.x86_64                     7/40
  Verifying        : libtiff-4.0.9-17.el8.x86_64                           8/40
  Verifying        : libwebp-1.0.0-1.el8.x86_64                            9/40
  Verifying        : libxcb-1.13.1-1.el8.x86_64                           10/40
  Verifying        : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_6   11/40
  Verifying        : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e3   12/40
  Verifying        : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34   13/40
  Verifying        : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.   14/40
  Verifying        : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+   15/40
  Verifying        : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0   16/40
  Verifying        : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fe   17/40
  Verifying        : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34   18/40
  Verifying        : dejavu-fonts-common-2.35-6.el8.noarch                19/40
  Verifying        : dejavu-sans-fonts-2.35-6.el8.noarch                  20/40
  Verifying        : fontconfig-2.13.1-3.el8.x86_64                       21/40
  Verifying        : fontpackages-filesystem-1.44-22.el8.noarch           22/40
  Verifying        : libxslt-1.1.32-4.el8.x86_64                          23/40
  Verifying        : perl-Carp-1.42-396.el8.noarch                        24/40
  Verifying        : perl-Errno-1.28-416.el8.x86_64                       25/40
  Verifying        : perl-Exporter-5.72-396.el8.noarch                    26/40
  Verifying        : perl-File-Path-2.15-2.el8.noarch                     27/40
  Verifying        : perl-IO-1.38-416.el8.x86_64                          28/40
  Verifying        : perl-PathTools-3.74-1.el8.x86_64                     29/40
  Verifying        : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64           30/40
  Verifying        : perl-Socket-4:2.027-3.el8.x86_64                     31/40
  Verifying        : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch         32/40
  Verifying        : perl-Unicode-Normalize-1.25-396.el8.x86_64           33/40
  Verifying        : perl-constant-1.33-396.el8.noarch                    34/40
  Verifying        : perl-interpreter-4:5.26.3-416.el8.x86_64             35/40
  Verifying        : perl-libs-4:5.26.3-416.el8.x86_64                    36/40
  Verifying        : perl-macros-4:5.26.3-416.el8.x86_64                  37/40
  Verifying        : perl-parent-1:0.237-1.el8.noarch                     38/40
  Verifying        : perl-threads-1:2.21-2.el8.x86_64                     39/40
  Verifying        : perl-threads-shared-1.58-2.el8.x86_64                40/40

Installed:
  dejavu-fonts-common-2.35-6.el8.noarch
  dejavu-sans-fonts-2.35-6.el8.noarch
  fontconfig-2.13.1-3.el8.x86_64
  fontpackages-filesystem-1.44-22.el8.noarch
  gd-2.2.5-6.el8.x86_64
  jbigkit-libs-2.1-14.el8.x86_64
  libX11-1.6.8-3.el8.x86_64
  libX11-common-1.6.8-3.el8.noarch
  libXau-1.0.8-13.el8.x86_64
  libXpm-3.5.12-8.el8.x86_64
  libjpeg-turbo-1.5.3-10.el8.x86_64
  libtiff-4.0.9-17.el8.x86_64
  libwebp-1.0.0-1.el8.x86_64
  libxcb-1.13.1-1.el8.x86_64
  libxslt-1.1.32-4.el8.x86_64
  nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
  nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64
  perl-Carp-1.42-396.el8.noarch
  perl-Errno-1.28-416.el8.x86_64
  perl-Exporter-5.72-396.el8.noarch
  perl-File-Path-2.15-2.el8.noarch
  perl-IO-1.38-416.el8.x86_64
  perl-PathTools-3.74-1.el8.x86_64
  perl-Scalar-List-Utils-3:1.49-2.el8.x86_64
  perl-Socket-4:2.027-3.el8.x86_64
  perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch
  perl-Unicode-Normalize-1.25-396.el8.x86_64
  perl-constant-1.33-396.el8.noarch
  perl-interpreter-4:5.26.3-416.el8.x86_64
  perl-libs-4:5.26.3-416.el8.x86_64
  perl-macros-4:5.26.3-416.el8.x86_64
  perl-parent-1:0.237-1.el8.noarch
  perl-threads-1:2.21-2.el8.x86_64
  perl-threads-shared-1.58-2.el8.x86_64

Complete!

Step 3: Enable and Start Nginx

sudo systemctl enable nginx
sudo systemctl start nginx

Result:

[root@tutorialspots ~]# sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@tutorialspots ~]# sudo systemctl start nginx

Step 4: If you are running a firewall, run the following commands to allow HTTP and HTTPS traffic:

systemctl enable firewalld.service
systemctl start firewalld.service
sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Done!, now you can access your website in your web browser

http://server_domain_name_or_IP/

Example: http://136.243.62.225/

nginx centos 8

1 Comment

Leave a Reply