Otu esi etinye Nginx Mainline kacha ọhụrụ ma ọ bụ Stable na Debian 11

Maka ndị na-eji Debian 11, ị nwere ike chọpụtala na wụnye Nginx kpọmkwem site na Ebe nchekwa Debian anaghị etinye ya na ọhụrụ kwụsiri ike ma ọ bụ mainline version. Ọ mara mma n'azụ ebe Nginx kwụsiri ike, Mainline nọ n'oge mmepe ya ugbu a.

Maka ọtụtụ, iji Nginx ndabara nke na-abịa na Debian ga-amasị ya, mana maka ndị chọrọ iji nsụgharị ọhụrụ maka njirimara ọhụrụ, nkuzi na-esonụ ga-ekpuchi usoro ndị dị mkpa iji mee nke a.

Prerequisites

  • OS akwadoro: Nnenna 11 Bullseye
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo ma ọ bụ ohere mgbọrọgwụ.

Melite Sistemụ Ọrụ

Melite gi Debian Sistemụ arụmọrụ iji hụ na ngwugwu niile dị adị adịla ugbu a:

sudo apt update && sudo apt upgrade -y

Nkuzi a ga-eji ya sudo iwu na na-eche na ị nwere ọnọdụ sudo.

Iji nyochaa ọkwa sudo na akaụntụ gị:

sudo whoami

Ihe atụ na-egosi ọkwa sudo:

[joshua@debian~]$ sudo whoami
root

Ka ịtọlite ​​akaụntụ sudo dị adị ma ọ bụ ọhụrụ, gaa na nkuzi anyị na Ịgbakwunye onye ọrụ na Sudoers na Debian.

Iji mgbọrọgwụ akaụntụ, jiri iwu na-esonụ na paswọọdụ mgbọrọgwụ banye.

su

Advertisement


Wepu nwụnye Nginx gara aga

Mbụ, ịkwesịrị wepụ ọ bụla Nginx gara aga ndị na-arụ ọrụ tupu ịwụnye Nginx Mainline.

Kwụsị Nginx iji sistemụ nye iwu dika ndi a:

systemctl stop nginx

Mepụta otu nke gị nginx.conf faịlụ maka nkwado ndabere na mpaghara ọ bụrụ na ị defere ma ọ bụ hichapụ nke ị dị na mberede:

cp /etc/nginx/nginx.conf /etc/nginx/nginx-backup.conf

Na-esote, wepụ Nginx site na iji iwu a:

apt remove nginx

Wụnye ngwugwu achọrọ

A ga-achọrọ ụfọdụ ngwugwu agbakwunyere iji wụnye ụdị Nginx kacha ọhụrụ ma ọ bụ kwụsie ike site na ebe nchekwa Nginx gọọmentị. Gbaa iwu a ka ịwụnye ma ọ bụ nyochaa ma etinyere ha na sistemụ Debian Bullseye gị:

apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring

Advertisement


Bubata Ngnix Repositories

Na-esote, a ga-achọ usoro ole na ole iji bubata ebe nchekwa dị ka ndị a nke ọma.

Bubata igodo GPG

na iji iwu iwu, bubata igodo GPG ka onye njikwa ngwugwu APT wee nwee ike nyochaa izi ezi nke ngwugwu Nginx mainline:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Igodo GPG

Na-esote, a na-atụ aro ka ịnwale na nyochaa faịlụ nbudata nwere igodo kwesịrị ekwesị. Iji mee nke a, jiri iwu a na njedebe gị:

gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

Mbupute ihe atụ kwesịrị ịpụta:

pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid                      nginx signing key <signing-key@nginx.com>

Bubata Nginx Mainline Repository

Ka ịtọlite ​​​​na ibubata ebe nchekwa Nginx Mainline, mee iwu a na ọdụ gị:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Bubata Nginx Stable Repository

Otu ihe dị ka Nginx Mainline dị n'elu, maka Nginx Stable, jiri iwu na-esonụ na njedebe gị:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Tinye Nginx Repository Version ka ịwụnye

Na-esote, jiri iwu pinning na-esonụ iji mee ka Debian jiri Nginx's repository n'elu ebe nchekwa Debian Nginx ndabara:

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

Ihe atụ mmepụta:

se o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
Package: *
Pin: origin nginx.org
Pin: release o=nginx
Pin-Priority: 900

Wụnye Nginx Mainline ma ọ bụ Stable

Ugbu a ị melitela ebe nchekwa ahụ, tupu ịmebe iwu Nginx install, ịkwesịrị imelite ndepụta nchekwa gị iji gosipụta mgbanwe ọhụrụ dị ka ndị a:

apt update

Na-esote, gbaa iwu Nginx install, nke a ga-arụnye ụdị Nginx ọhụrụ nke ebe nchekwa ị webatara nke bụ isi ma ọ bụ kwụsie ike:

apt install nginx -y

Rịba ama na enwere ike ịkpali gị idowe ma ọ bụ dochie gị dị / wdg / nginx /nginx.conf nhazi faịlụ n'oge echichi. A na-atụ aro ka idobe faịlụ nhazi gị ugbu a site na ịpị (n). A ga-eme otu n'agbanyeghị ụdị onye na-elekọta ya, ma ị nwekwara ike ịlele nke a n'ọdịnihu.

Nyochaa ma ọ bụrụ na arụnyere Nginx nke ọma yana na ụdị kachasị ọhụrụ site na iji iwu a:

sudo nginx -v

Ihe atụ (Nginx Mainline Example)

nginx version: nginx/1.21.1

Dịka n'elu, ụdị arụnyere n'oge edere nke ọma bụ ụdị Nginx Mainline kacha ọhụrụ.

Site na ndabara, ekwesịrị ịgbanye Nginx ma ọ bụrụ na agbaghị ya ọrụ. jiri:

sudo systemctl start nginx

Iji mee ka Nginx malite na buut, jiri iwu a:

sudo systemctl enable nginx

Mwepụta ihe atụ ma ọ bụrụ na ọ ga nke ọma:

Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx

Chọpụta ọkwa Nginx:

sudo systemctl status nginx

Ihe atụ mmepụta:

nginx kacha ọhụrụ ụdị debian 11 systemctl dị mma

Advertisement


Na-emelite Nginx

Maka mmelite n'ọdịnihu, naanị ihe ị ga-eme bụ ịgba ọsọ njikwa ngwugwu APT ka ị ga-elele sistemụ gị maka mmelite dịka ọ na-adị.

apt update

Ọ bụrụ na mmelite dị, mee iwu na-esonụ, nke bụ otu ihe ahụ dị ka mmalite nke nkuzi maka imelite sistemụ Debian gị:

apt upgrade

Nhọrọ nwụnye ọzọ – Ebe nchekwa nchekwa Surý

Ụzọ ọzọ bụ ịwụnye Nginx mainline ma ọ bụ kwụsiri ike site na ebe nchekwa Ondřej Surý. Ọtụtụ ndị ọrụ Ubuntu ga-ama PPA ya, ị nwekwara ike ime otu ihe ahụ nke ukwuu na Debian.

Iji jiri ụdị Nginx kacha ọhụrụ ma ọ bụ kwụsie ike, ị ga-ebu ụzọ bubata ebe nchekwa ahụ.

Iji bubata ebe nchekwa mainline:

curl -sSL https://packages.sury.org/nginx-mainline/README.txt | sudo bash -x

Ka ibubata ebe nchekwa kwụsiri ike:

curl -sSL https://packages.sury.org/nginx/README.txt | sudo bash -x

Melite ebe nchekwa gị iji gosipụta mgbanwe ọhụrụ:

apt update

Ugbu a ị wụnyela Nginx ebe nchekwa wee melite ndepụta nchekwa, tinye Nginx na ihe ndị a:

apt install nginx-core nginx-common nginx nginx-full

Ihe atụ mmepụta:

Otu esi etinye Nginx Mainline kacha ọhụrụ ma ọ bụ Stable na Debian 11

Pịnye Y, mgbe ahụ, pịa igodo ntinye ịga n'ihu na mezue nrụnye.

Rịba ama na enwere ike ịkpali gị idowe ma ọ bụ dochie gị dị / wdg / nginx /nginx.conf nhazi faịlụ n'oge echichi. A na-atụ aro ka idobe faịlụ nhazi gị ugbu a site na ịpị (n). A ga-eme otu n'agbanyeghị ụdị onye na-elekọta ya, ma ị nwekwara ike ịlele nke a n'ọdịnihu.

Ị ga-achọpụta na modul ndị ọzọ ga-adị na ụdị a, karịsịa nkwado brotli. Iji wụnye brotli, soro usoro ndị a n'okpuru.

mepee gị nginx.conf nhazi faịlụ:

nano /etc/nginx/nginx.conf

Ugbu a tinye ahịrị ndị ọzọ tupu na nke HTTP{} ngalaba:

        brotli on;
        brotli_comp_level 6;
        brotli_static on;
        brotli_types application/atom+xml application/javascript application/json application/rss+xml
             application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
             application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
             font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
             image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;

The brotli_comp_level enwere ike ịtọ n'etiti 1 (kasị ala) na 11 (kachasị elu). Dịka, ọtụtụ sava na-anọdụ n'etiti, mana ọ bụrụ na ihe nkesa gị bụ nnukwu anụ, tọọ 11 wee lelee ọkwa ojiji CPU.

Na-esote, nwalee ka ijide n'aka na mgbanwe ndị a na-arụ ọrụ nke ọma tupu ime mgbanwe ndị a dị ndụ:

sudo nginx -t

Ọ bụrụ na mgbanwe ndị a na-arụ ọrụ nke ọma, ị ga-ahụ ihe ndị a:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Ugbu a mee mgbanwe ndị a dị ndụ site na ịmalitegharị ihe nkesa gị:

sudo systemctl restart nginx

Advertisement


Okwu na mmechi

Nkuzi ahụ egosila gị otu esi etinye ebe nchekwa Nginx ka ị nwee ike ịdọrọ ma ọ bụ Nginx kwụ ọtọ ma ọ bụ ụdị kachasị ọhụrụ na sistemụ Debian Bullseye gị yana usoro ọzọ sitere na Ondřej Surý. Nkwụsi ike bụ iji ihe na-abịa n'ihu ọha na ebe nchekwa Debian APT. Otú ọ dị, ọtụtụ mgbe, ndị a enweghị atụmatụ ebe ọ bụ na ha bụ oge ochie.

N'ozuzu, iji ụdị Nginx ma ọ bụ Mainline kwụsiri ike kachasị ọhụrụ adịghị mma ma e jiri ya tụnyere ngwanrọ ndị ọzọ ebe ahụhụ na enweghị ntụkwasị obi nwere ike ịdị. Nginx na-arụ ọrụ dị egwu na idobe ngwa weebụ ya nke ọma.

Ahapụ a Comment