centos8中一键安装Nginx

1:检查是否安装

[root@aa ~]# nginx -v
-bash: nginx: command not found

2:一键安装yum install -y nginx

[root@aa ~]# yum install -y nginx
Last metadata expiration check: 0:43:45 ago on Sun 29 Aug 2021 09:40:34 AM CST.
Dependencies resolved.
===============================================================================================================================================================================================================
 Package                                                  Architecture                        Version                                                             Repository                              Size
===============================================================================================================================================================================================================
Installing:
 nginx                                                    x86_64                              1:1.14.1-9.module_el8.0.0+184+e34fea82                              AppStream                              570 k
Installing dependencies:
 gd                                                       x86_64                              2.2.5-7.el8                                                         AppStream                              144 k
 jbigkit-libs                                             x86_64                              2.1-14.el8                                                          AppStream                               55 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-18.el8                                                        AppStream                              188 k
 libwebp                                                  x86_64                              1.0.0-3.el8_4                                                       AppStream                              272 k
 libxslt                                                  x86_64                              1.1.32-6.el8                                                        BaseOS                                 250 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
Enabling module streams:
 nginx                                                                                        1.14                                                                                                            

Transaction Summary
===============================================================================================================================================================================================================
Install  15 Packages

Total download size: 2.0 M
Installed size: 5.2 M
Downloading Packages:
(1/15): libXpm-3.5.12-8.el8.x86_64.rpm                                                                                                                                         4.8 MB/s |  58 kB     00:00    
(2/15): jbigkit-libs-2.1-14.el8.x86_64.rpm                                                                                                                                     4.2 MB/s |  55 kB     00:00    
(3/15): gd-2.2.5-7.el8.x86_64.rpm                                                                                                                                              7.2 MB/s | 144 kB     00:00    
(4/15): libjpeg-turbo-1.5.3-10.el8.x86_64.rpm                                                                                                                                  8.9 MB/s | 156 kB     00:00    
(5/15): libtiff-4.0.9-18.el8.x86_64.rpm                                                                                                                                        8.5 MB/s | 188 kB     00:00    
(6/15): libwebp-1.0.0-3.el8_4.x86_64.rpm                                                                                                                                        12 MB/s | 272 kB     00:00    
(7/15): nginx-all-modules-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm                                                                                                      370 kB/s |  23 kB     00:00    
(8/15): nginx-filesystem-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm                                                                                                       312 kB/s |  24 kB     00:00    
(9/15): nginx-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                                                  5.5 MB/s | 570 kB     00:00    
(10/15): nginx-mod-http-image-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                           491 kB/s |  35 kB     00:00    
(11/15): nginx-mod-http-perl-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                                   633 kB/s |  45 kB     00:00    
(12/15): nginx-mod-http-xslt-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                            480 kB/s |  33 kB     00:00    
(13/15): libxslt-1.1.32-6.el8.x86_64.rpm                                                                                                                                        17 MB/s | 250 kB     00:00    
(14/15): nginx-mod-mail-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                                        818 kB/s |  64 kB     00:00    
(15/15): nginx-mod-stream-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64.rpm                                                                                                      1.1 MB/s |  85 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                          7.2 MB/s | 2.0 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                       1/1 
  Installing       : libjpeg-turbo-1.5.3-10.el8.x86_64                                                                                                                                                    1/15 
  Installing       : libxslt-1.1.32-6.el8.x86_64                                                                                                                                                          2/15 
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                       3/15 
  Installing       : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                       3/15 
  Installing       : libwebp-1.0.0-3.el8_4.x86_64                                                                                                                                                         4/15 
  Installing       : libXpm-3.5.12-8.el8.x86_64                                                                                                                                                           5/15 
  Installing       : jbigkit-libs-2.1-14.el8.x86_64                                                                                                                                                       6/15 
  Running scriptlet: jbigkit-libs-2.1-14.el8.x86_64                                                                                                                                                       6/15 
  Installing       : libtiff-4.0.9-18.el8.x86_64                                                                                                                                                          7/15 
  Installing       : gd-2.2.5-7.el8.x86_64                                                                                                                                                                8/15 
  Running scriptlet: gd-2.2.5-7.el8.x86_64                                                                                                                                                                8/15 
  Installing       : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                    9/15 
  Running scriptlet: nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                    9/15 
  Installing       : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                            10/15 
  Running scriptlet: nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                            10/15 
  Installing       : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                        11/15 
  Running scriptlet: nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                        11/15 
  Installing       : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                      12/15 
  Running scriptlet: nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                      12/15 
  Installing       : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                                 13/15 
  Running scriptlet: nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                                 13/15 
  Installing       : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                           14/15 
  Running scriptlet: nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                           14/15 
  Installing       : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                     15/15 
  Running scriptlet: nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                     15/15 
  Verifying        : gd-2.2.5-7.el8.x86_64                                                                                                                                                                1/15 
  Verifying        : jbigkit-libs-2.1-14.el8.x86_64                                                                                                                                                       2/15 
  Verifying        : libXpm-3.5.12-8.el8.x86_64                                                                                                                                                           3/15 
  Verifying        : libjpeg-turbo-1.5.3-10.el8.x86_64                                                                                                                                                    4/15 
  Verifying        : libtiff-4.0.9-18.el8.x86_64                                                                                                                                                          5/15 
  Verifying        : libwebp-1.0.0-3.el8_4.x86_64                                                                                                                                                         6/15 
  Verifying        : nginx-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                                  7/15 
  Verifying        : nginx-all-modules-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                      8/15 
  Verifying        : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                                                                                                                       9/15 
  Verifying        : nginx-mod-http-image-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                           10/15 
  Verifying        : nginx-mod-http-perl-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                   11/15 
  Verifying        : nginx-mod-http-xslt-filter-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                            12/15 
  Verifying        : nginx-mod-mail-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                        13/15 
  Verifying        : nginx-mod-stream-1:1.14.1-9.module_el8.0.0+184+e34fea82.x86_64                                                                                                                      14/15 
  Verifying        : libxslt-1.1.32-6.el8.x86_64                                                                                                                                                         15/15 

Installed:
  gd-2.2.5-7.el8.x86_64                                                                                      jbigkit-libs-2.1-14.el8.x86_64                                                                    
  libXpm-3.5.12-8.el8.x86_64                                                                                 libjpeg-turbo-1.5.3-10.el8.x86_64                                                                 
  libtiff-4.0.9-18.el8.x86_64                                                                                libwebp-1.0.0-3.el8_4.x86_64                                                                      
  libxslt-1.1.32-6.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                                            

Complete!
[root@aa ~]# nginx -v
nginx version: nginx/1.14.1

3:查看安装的编译模块

[root@aa ~]# nginx -V
nginx version: nginx/1.14.1
built by gcc 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC) 
built with OpenSSL 1.1.1 FIPS  11 Sep 2018 (running with OpenSSL 1.1.1c FIPS  28 May 2019)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

4:启动nginx

[root@aa ~]# systemctl start nginx.service
[root@aa ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      45194/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      45194/nginx: master 

5:开机自动运行

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

猜你喜欢

转载自blog.csdn.net/wind520/article/details/119977519
今日推荐