45 openEuler搭建Nginx服務器-Nginx概述和安裝45.1 概述45.2 安裝
45 openEuler搭建Nginx服務器-Nginx概述和安裝
45.1 概述
Nginx 是一款輕量級的 Web 服務器/反向代理服務器及電子郵件(IMAP/POP3)代理服務器,其特點是占用內存少气笙,并發(fā)能力強,事實上nginx的并發(fā)能力在同類型的網頁服務器中表現(xiàn)較好,支持FastCGI闸天、SSL侦鹏、Virtual Host湾盒、URL Rewrite、Gzip等功能痰憎,并且支持很多第三方的模塊擴展。
Nginx (engine x) 是一個高性能的HTTP和反向代理web服務器 攀涵,同時也提供了IMAP/POP3/SMTP服務铣耘。Nginx是由伊戈爾·賽索耶夫為俄羅斯訪問量第二的Rambler.ru站點(俄文:Рамблер)開發(fā)的,公開版本1.19.6發(fā)布于2020年12月15日以故。
其將源代碼以類BSD許可證的形式發(fā)布蜗细,因它的穩(wěn)定性、豐富的功能集怒详、簡單的配置文件和低系統(tǒng)資源的消耗而聞名炉媒。2022年01月25日,nginx 1.21.6發(fā)布昆烁。
45.2 安裝
配置本地yum源吊骤,詳細信息請參考《openEuler 22.03-LTS 搭建repo服務器》。
清除緩存静尼。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n16" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># dnf clean all</pre>
例如示例命令如下:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n18" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@superman-21 ~]# dnf clean all
36 files removed
[root@superman-21 ~]# </pre>
- 創(chuàng)建緩存白粉。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n22" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># dnf makecache</pre>
例如示例命令如下:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n24" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@superman-21 ~]# dnf makecache
OS 6.8 MB/s | 3.4 MB 00:00
everything 19 MB/s | 16 MB 00:00
EPOL 3.9 MB/s | 2.6 MB 00:00
debuginfo 3.3 MB/s | 3.9 MB 00:01
source 1.1 MB/s | 1.7 MB 00:01
update 25 MB/s | 28 MB 00:01
Metadata cache created.
[root@superman-21 ~]#</pre>
- 在root權限下安裝nginx服務。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n28" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># dnf install nginx</pre>
例如示例命令如下:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n30" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@superman-21 ~]# dnf install nginx
Last metadata expiration check: 0:00:34 ago on 2022年12月03日 星期六 10時39分32秒.
Dependencies resolved.
=============================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================
Installing:
nginx x86_64 1:1.21.5-3.oe2203 update 498 k
Installing dependencies:
gd x86_64 2.3.2-2.oe2203 update 127 k
libXpm x86_64 3.5.13-1.oe2203 OS 41 k
libwebp x86_64 1.2.1-1.oe2203 OS 246 k
nginx-all-modules noarch 1:1.21.5-3.oe2203 update 7.6 k
nginx-filesystem noarch 1:1.21.5-3.oe2203 update 8.7 k
nginx-mod-http-image-filter x86_64 1:1.21.5-3.oe2203 update 18 k
nginx-mod-http-perl x86_64 1:1.21.5-3.oe2203 update 27 k
nginx-mod-http-xslt-filter x86_64 1:1.21.5-3.oe2203 update 17 k
nginx-mod-mail x86_64 1:1.21.5-3.oe2203 update 49 k
nginx-mod-stream x86_64 1:1.21.5-3.oe2203 update 71 k
Transaction Summary
Install 11 Packages
Total download size: 1.1 M
Installed size: 3.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/11): libXpm-3.5.13-1.oe2203.x86_64.rpm 248 kB/s | 41 kB 00:00
(2/11): gd-2.3.2-2.oe2203.x86_64.rpm 562 kB/s | 127 kB 00:00
(3/11): nginx-all-modules-1.21.5-3.oe2203.noarch.rpm 168 kB/s | 7.6 kB 00:00
(4/11): nginx-filesystem-1.21.5-3.oe2203.noarch.rpm 186 kB/s | 8.7 kB 00:00
(5/11): nginx-mod-http-image-filter-1.21.5-3.oe2203.x86_64.rpm 385 kB/s | 18 kB 00:00
(6/11): libwebp-1.2.1-1.oe2203.x86_64.rpm 611 kB/s | 246 kB 00:00
(7/11): nginx-mod-http-perl-1.21.5-3.oe2203.x86_64.rpm 431 kB/s | 27 kB 00:00
(8/11): nginx-mod-http-xslt-filter-1.21.5-3.oe2203.x86_64.rpm 395 kB/s | 17 kB 00:00
(9/11): nginx-mod-mail-1.21.5-3.oe2203.x86_64.rpm 816 kB/s | 49 kB 00:00
(10/11): nginx-mod-stream-1.21.5-3.oe2203.x86_64.rpm 791 kB/s | 71 kB 00:00
(11/11): nginx-1.21.5-3.oe2203.x86_64.rpm 1.1 MB/s | 498 kB 00:00
Total 1.7 MB/s | 1.1 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-filesystem-1:1.21.5-3.oe2203.noarch 1/11
Installing : nginx-filesystem-1:1.21.5-3.oe2203.noarch 1/11
Installing : libwebp-1.2.1-1.oe2203.x86_64 2/11
Installing : libXpm-3.5.13-1.oe2203.x86_64 3/11
Installing : gd-2.3.2-2.oe2203.x86_64 4/11
Running scriptlet: gd-2.3.2-2.oe2203.x86_64 4/11
Installing : nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64 5/11
Running scriptlet: nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64 5/11
Installing : nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64 6/11
Running scriptlet: nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64 6/11
Installing : nginx-mod-mail-1:1.21.5-3.oe2203.x86_64 7/11
Running scriptlet: nginx-mod-mail-1:1.21.5-3.oe2203.x86_64 7/11
Installing : nginx-mod-stream-1:1.21.5-3.oe2203.x86_64 8/11
Running scriptlet: nginx-mod-stream-1:1.21.5-3.oe2203.x86_64 8/11
Installing : nginx-1:1.21.5-3.oe2203.x86_64 9/11
Running scriptlet: nginx-1:1.21.5-3.oe2203.x86_64 9/11
Installing : nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64 10/11
Running scriptlet: nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64 10/11
Installing : nginx-all-modules-1:1.21.5-3.oe2203.noarch 11/11
Running scriptlet: nginx-all-modules-1:1.21.5-3.oe2203.noarch 11/11
Verifying : libXpm-3.5.13-1.oe2203.x86_64 1/11
Verifying : libwebp-1.2.1-1.oe2203.x86_64 2/11
Verifying : gd-2.3.2-2.oe2203.x86_64 3/11
Verifying : nginx-1:1.21.5-3.oe2203.x86_64 4/11
Verifying : nginx-all-modules-1:1.21.5-3.oe2203.noarch 5/11
Verifying : nginx-filesystem-1:1.21.5-3.oe2203.noarch 6/11
Verifying : nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64 7/11
Verifying : nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64 8/11
Verifying : nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64 9/11
Verifying : nginx-mod-mail-1:1.21.5-3.oe2203.x86_64 10/11
Verifying : nginx-mod-stream-1:1.21.5-3.oe2203.x86_64 11/11
Installed:
gd-2.3.2-2.oe2203.x86_64 libXpm-3.5.13-1.oe2203.x86_64
libwebp-1.2.1-1.oe2203.x86_64 nginx-1:1.21.5-3.oe2203.x86_64
nginx-all-modules-1:1.21.5-3.oe2203.noarch nginx-filesystem-1:1.21.5-3.oe2203.noarch
nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64 nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64
nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64 nginx-mod-mail-1:1.21.5-3.oe2203.x86_64
nginx-mod-stream-1:1.21.5-3.oe2203.x86_64
Complete!
[root@superman-21 ~]# </pre>
- 查看安裝后的rpm包鼠渺。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n34" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># dnf list all | grep nginx</pre>
例如示例命令如下:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n36" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@superman-21 ~]# dnf list all | grep nginx
nginx.x86_64 1:1.21.5-3.oe2203 @update
nginx-all-modules.noarch 1:1.21.5-3.oe2203 @update
nginx-filesystem.noarch 1:1.21.5-3.oe2203 @update
nginx-mod-http-image-filter.x86_64 1:1.21.5-3.oe2203 @update
nginx-mod-http-perl.x86_64 1:1.21.5-3.oe2203 @update
nginx-mod-http-xslt-filter.x86_64 1:1.21.5-3.oe2203 @update
nginx-mod-mail.x86_64 1:1.21.5-3.oe2203 @update
nginx-mod-stream.x86_64 1:1.21.5-3.oe2203 @update
nginx.src 1:1.21.5-1.oe2203 source
nginx-debuginfo.x86_64 1:1.21.5-3.oe2203 update
nginx-debugsource.x86_64 1:1.21.5-3.oe2203 update
nginx-help.noarch 1:1.21.5-3.oe2203 update
pcp-pmda-nginx.x86_64 5.3.5-6.oe2203 OS
pcp-pmda-nginx.x86_64 5.3.5-6.oe2203 everything
[root@superman-21 ~]# </pre>
?? 點贊鸭巴,你的認可是我創(chuàng)作的動力!
?? 收藏系冗,你的青睞是我努力的方向奕扣!
?? 評論,你的意見是我進步的財富掌敬!