在Rocky Linux 8.10上安装Nginx

发布于:2025-05-23 ⋅ 阅读:(17) ⋅ 点赞:(0)

如果没有配置操作系统安装源,并且不连接网络,先配置安装源。

sudo dnf install nginx

sudo systemctl enable nginx
sudo systemctl start nginx

systemctl status nginx

curl http://ip

[root@rocky810 work]# sudo dnf install nginx
Last metadata expiration check: 0:03:19 ago on Thu 22 May 2025 10:25:40 AM CST.
Dependencies resolved.
========================================================================================================================================================================= Package                                          Architecture                Version                                                     Repository                Size
=========================================================================================================================================================================Installing:
 nginx                                            x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                      566 k
Installing dependencies:
 nginx-all-modules                                noarch                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       22 k
 nginx-filesystem                                 noarch                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       23 k
 nginx-mod-http-image-filter                      x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       34 k
 nginx-mod-http-perl                              x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       45 k
 nginx-mod-http-xslt-filter                       x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       32 k
 nginx-mod-mail                                   x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       63 k
 nginx-mod-stream                                 x86_64                      1:1.14.1-9.module+el8.4.0+542+81547229                      APP                       84 k
Enabling module streams:
 nginx                                                                        1.14                                                                                      

Transaction Summary
=========================================================================================================================================================================Install  8 Packages

Total size: 870 k
Installed size: 2.0 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                                                                                  1/8 
  Installing       : nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                                                                                  1/8 
  Installing       : nginx-mod-http-image-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                       2/8 
  Running scriptlet: nginx-mod-http-image-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                       2/8 
  Installing       : nginx-mod-http-perl-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                               3/8 
  Running scriptlet: nginx-mod-http-perl-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                               3/8 
  Installing       : nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                        4/8 
  Running scriptlet: nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                        4/8 
  Installing       : nginx-mod-mail-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                    5/8 
  Running scriptlet: nginx-mod-mail-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                    5/8 
  Installing       : nginx-all-modules-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                                                                                 6/8 
  Installing       : nginx-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                             7/8 
  Running scriptlet: nginx-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                             7/8 
  Installing       : nginx-mod-stream-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                  8/8 
  Running scriptlet: nginx-mod-stream-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                  8/8 
  Verifying        : nginx-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                             1/8 
  Verifying        : nginx-all-modules-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                                                                                 2/8 
  Verifying        : nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                                                                                  3/8 
  Verifying        : nginx-mod-http-image-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                       4/8 
  Verifying        : nginx-mod-http-perl-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                               5/8 
  Verifying        : nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                        6/8 
  Verifying        : nginx-mod-mail-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                    7/8 
  Verifying        : nginx-mod-stream-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                                                                                  8/8 

Installed:
  nginx-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                             nginx-all-modules-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                        
  nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                  nginx-mod-http-image-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64              
  nginx-mod-http-perl-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64               nginx-mod-http-xslt-filter-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64               
  nginx-mod-mail-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                    nginx-mod-stream-1:1.14.1-9.module+el8.4.0+542+81547229.x86_64                         

Complete!
[root@rocky810 work]# sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@rocky810 work]# sudo systemctl start nginx
[root@rocky810 work]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2025-05-22 10:29:29 CST; 17s ago
  Process: 18283 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 18111 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 18102 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 18303 (nginx)
    Tasks: 5 (limit: 100490)
   Memory: 11.7M
   CGroup: /system.slice/nginx.service
           ├─18303 nginx: master process /usr/sbin/nginx
           ├─18304 nginx: worker process
           ├─18305 nginx: worker process
           ├─18306 nginx: worker process
           └─18307 nginx: worker process

May 22 10:29:28 rocky810 systemd[1]: Starting The nginx HTTP and reverse proxy server...
May 22 10:29:28 rocky810 nginx[18111]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
May 22 10:29:28 rocky810 nginx[18111]: nginx: configuration file /etc/nginx/nginx.conf test is successful
May 22 10:29:29 rocky810 systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@rocky810 work]# curl http://10.11.13.60
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Test Page for the Nginx HTTP Server on Rocky Linux</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
      /*<![CDATA[*/
      body {
        background-color: #fff;
        color: #000;
        font-size: 0.9em;
        font-family: sans-serif, helvetica;
        margin: 0;
        padding: 0;
      }
      :link {
        color: #c00;
      }
      :visited {
        color: #c00;
      }
      a:hover {
        color: #f50;
      }
      h1 {
        text-align: center;
        margin: 0;
        padding: 0.6em 2em 0.4em;
        background-color: #10B981;
        color: #fff;
        font-weight: normal;
        font-size: 1.75em;
        border-bottom: 2px solid #000;
      }
      h1 strong {
        font-weight: bold;
        font-size: 1.5em;
      }
      h2 {
        text-align: center;
        background-color: #10B981;
        font-size: 1.1em;
        font-weight: bold;
        color: #fff;
        margin: 0;
        padding: 0.5em;
        border-bottom: 2px solid #000;
      }
      hr {
        display: none;
      }
      .content {
        padding: 1em 5em;
      }
      .alert {
        border: 2px solid #000;
      }

      img {
        border: 2px solid #fff;
        padding: 2px;
        margin: 2px;
      }
      a:hover img {
        border: 2px solid #294172;
      }
      .logos {
        margin: 1em;
        text-align: center;
      }
      /*]]>*/
    </style>
  </head>

  <body>
    <h1>Welcome to <strong>nginx</strong> on Rocky Linux!</h1>

    <div class="content">
      <p>
        This page is used to test the proper operation of the
        <strong>nginx</strong> HTTP server after it has been installed. If you
        can read this page, it means that the web server installed at this site
        is working properly.
      </p>

      <div class="alert">
        <h2>Website Administrator</h2>
        <div class="content">
          <p>
            This is the default <tt>index.html</tt> page that is distributed
            with <strong>nginx</strong> on Rocky Linux. It is located in
            <tt>/usr/share/nginx/html</tt>.
          </p>

          <p>
            You should now put your content in a location of your choice and
            edit the <tt>root</tt> configuration directive in the
            <strong>nginx</strong>
            configuration file
            <tt>/etc/nginx/nginx.conf</tt>.
          </p>

          <p>
            For information on Rocky Linux, please visit the
            <a href="https://www.rockylinux.org/">Rocky Linux website</a>. The
            documentation for Rocky Linux is
            <a href="https://www.rockylinux.org/"
              >available on the Rocky Linux website</a
            >.
          </p>
        </div>
      </div>

      <div class="logos">
        <a href="http://nginx.net/"
          ><img
            src="nginx-logo.png"
            alt="[ Powered by nginx ]"
            width="121"
            height="32"
        /></a>
        <a href="http://www.rockylinux.org/"><img
            src="poweredby.png"
            alt="[ Powered by Rocky Linux ]"
            width="88" height="31" /></a>
        
      </div>
    </div>
  </body>
</html>


网站公告

今日签到

点亮在社区的每一天
去签到