45 openEuler搭建Nginx服務器-Nginx概述和安裝

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 安裝

  1. 配置本地yum源吊骤,詳細信息請參考《openEuler 22.03-LTS 搭建repo服務器》。

  2. 清除緩存静尼。

<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>

  1. 創(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>

  1. 在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>

  1. 查看安裝后的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)作的動力!

?? 收藏系冗,你的青睞是我努力的方向奕扣!

?? 評論,你的意見是我進步的財富掌敬!

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末惯豆,一起剝皮案震驚了整個濱河市池磁,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌楷兽,老刑警劉巖地熄,帶你破解...
    沈念sama閱讀 222,000評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異芯杀,居然都是意外死亡端考,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,745評論 3 399
  • 文/潘曉璐 我一進店門揭厚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來却特,“玉大人,你說我怎么就攤上這事筛圆×衙鳎” “怎么了?”我有些...
    開封第一講書人閱讀 168,561評論 0 360
  • 文/不壞的土叔 我叫張陵太援,是天一觀的道長闽晦。 經常有香客問我,道長提岔,這世上最難降的妖魔是什么仙蛉? 我笑而不...
    開封第一講書人閱讀 59,782評論 1 298
  • 正文 為了忘掉前任,我火速辦了婚禮碱蒙,結果婚禮上荠瘪,老公的妹妹穿的比我還像新娘。我一直安慰自己振亮,他們只是感情好巧还,可當我...
    茶點故事閱讀 68,798評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著坊秸,像睡著了一般麸祷。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上褒搔,一...
    開封第一講書人閱讀 52,394評論 1 310
  • 那天阶牍,我揣著相機與錄音,去河邊找鬼星瘾。 笑死走孽,一個胖子當著我的面吹牛,可吹牛的內容都是我干的琳状。 我是一名探鬼主播磕瓷,決...
    沈念sama閱讀 40,952評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了困食?” 一聲冷哼從身側響起边翁,我...
    開封第一講書人閱讀 39,852評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎硕盹,沒想到半個月后符匾,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經...
    沈念sama閱讀 46,409評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡瘩例,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,483評論 3 341
  • 正文 我和宋清朗相戀三年啊胶,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片垛贤。...
    茶點故事閱讀 40,615評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡焰坪,死狀恐怖,靈堂內的尸體忽然破棺而出南吮,到底是詐尸還是另有隱情琳彩,我是刑警寧澤,帶...
    沈念sama閱讀 36,303評論 5 350
  • 正文 年R本政府宣布部凑,位于F島的核電站,受9級特大地震影響碧浊,放射性物質發(fā)生泄漏涂邀。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,979評論 3 334
  • 文/蒙蒙 一箱锐、第九天 我趴在偏房一處隱蔽的房頂上張望比勉。 院中可真熱鬧,春花似錦驹止、人聲如沸浩聋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,470評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽衣洁。三九已至,卻和暖如春抖仅,著一層夾襖步出監(jiān)牢的瞬間坊夫,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,571評論 1 272
  • 我被黑心中介騙來泰國打工撤卢, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留环凿,地道東北人。 一個月前我還...
    沈念sama閱讀 49,041評論 3 377
  • 正文 我出身青樓放吩,卻偏偏與公主長得像智听,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,630評論 2 359

推薦閱讀更多精彩內容