Otu esi etinye / kwalite Nginx Mainline/Stable kacha ọhụrụ na Ubuntu 20.04

Maka ndị na-eji Ubuntu 20.04 LTS, ị nwere ike chọpụtala na wụnye Nginx ozugbo site na ebe nchekwa ya anaghị wụnye ụdị kwụsiri ike ma ọ bụ nke kachasị ọhụrụ. Nke a bụ ihe a na-emekarị n'ọtụtụ nkesa na-elekwasị anya na nkwụsi ike nke ngwugwu ma na-enye naanị ahụhụ ma ọ bụ mmelite nchekwa ngwa ngwa ruo mgbe nkesa bụ isi na-esote.

Maka ọtụtụ, iji Nginx ndabara nke na-abịa jikọtara ya na ebe nchekwa ga-amasị ya, mana ọtụtụ mgbe ọtụtụ na-achọ ma na-achọ ụdị kwụsiri ike ma ọ bụ nke kachasị ọhụrụ maka njirimara emelitere. Nkuzi na-esote ga-ekpuchi ịwụnye ụdị Nginx ikpeazụ ma ọ bụ isi okwu na Ubuntu 20.04 LTS Focal Fossa.

Prerequisites

  • OS akwadoro: Ubuntu 20.04
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo or mgbọrọgwụ ohere.

Melite Sistemụ Ọrụ

Melite gi Ubuntu 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@ubuntu ~]$ sudo whoami
root

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

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 tupu ịwụnye ụdị Nginx ọhụrụ iji zere esemokwu.

Nke mbụ, kwado nhazi nginx gị maka nchekwa.

sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old

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

sudo systemctl stop nginx

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

sudo apt-get remove nginx*

Nhọrọ 1. NGINX Repository Installation

Ụzọ mbụ bụ ịwụnye na melite site na iji Nginx's repository, nke ga-enye gị oge niile ụdị kachasị ọhụrụ dị.

Mbụ, mepee ọnụ ụzọ gị (Ctrl+ALT+T) ma wụnye ndabere achọrọ maka mbubata na ịwụnye Nginx site na iji ebe nchekwa gọọmentị.

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

Budata ma gbakwunye igodo Nginx GPG iji nyochaa izi ezi nke ngwugwu.

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

Nyochaa igodo GPG site na iji iwu na-esonụ.

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

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

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

Na-esote, jiri ihe ndị a ka ịgbakwunye ebe nchekwa Nginx kwụsiri ike ma ọ bụ nke bụ isi n'ime ndepụta njikwa ngwugwu gị dabara adaba.

Import Nginx kwụsiri ike:

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

Bubata Nginx nnukwu ebe nchekwa:

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

Kwesịrị ịdị, ị kwesịrị ịtọ Mgbanwe nke APT ịhọrọ ngwugwu Nginx karịa ebe nchekwa Ubuntu ọ bụla ọzọ ma ọ bụ PPA. Enwere ike ime nke a site na iji iwu a.

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

Ozugbo emechara, melite ebe nchekwa dabara adaba iji gosipụta mgbakwunye ọhụrụ.

sudo apt update

Ugbu a gaa n'ihu ịwụnye Nginx.

sudo apt install nginx

N'ebe a, ị wụnyela ụdị Nginx kachasị ọhụrụ site na ebe nchekwa ọrụ ya.


Advertisement


Nhọrọ 2. Nwụnye Surý PPA Nginx

Ụzọ ọzọ maka ndị ọrụ na-ahọrọ ụzọ kwụ ọtọ karị bụ ịwụnye Nginx mainline site na Ondřej Surý, onye ọtụtụ ga-ama dị ka onye na-eduzi PHP onye mmepụta na onye na-elekọta Debian repositories. PPA a adịghị mma ma a na-edobe ya n'ime awa ruo ụbọchị ole na ole mgbe mmelite ọ bụla gachara site na Nginx.

PPA na-akwado ma kwụsiri ike yana isi okwu mana ha bụ nke PPA dị iche.

Iji bubata PPA kwụsiri ike:

sudo add-apt-repository ppa:ondrej/nginx -y
sudo apt update

Iji bubata PPA isi ahịrị:

sudo add-apt-repository ppa:ondrej/nginx-mainline
sudo apt update

Ozugbo agbakwunyere ebe nchekwa ahọpụtara, gaba n'ihu ịwụnye Nginx mainline n'uju site na iji iwu a:

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

Ma nke ahụ bụ ya! Ị tinyela ụdị Nginx kachasị ọhụrụ site na iji PPA nke Ondřej Surý.

Na mgbakwunye, PPA nwere ọtụtụ uru nke mgbakwunye modul gụnyere. Otu n'ime uru ndị bụ isi bụ inwe ikike ịgbakwunye nkwado Brotli. Iji wụnye brotli, soro usoro ndị a n'okpuru.

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

sudo 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 ka ọ 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

Mmechi & Nzaghachi:

Nkuzi ahụ egosila gị otu esi etinye ebe nchekwa Nginx ma ọ bụ PPA ka ị nwee ike ịdọrọ ma ọ bụ Nginx kwụ ọtọ ma ọ bụ ụdị kachasị ọhụrụ na sistemụ Ubuntu 20.04 LTS gị.

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.

Idenye aha
Gwa nke
3 Comments
Inline nzaghachi
Lee echiche niile

Daalụ! Edemede na-enyere aka nke ukwuu!

Daalụ nke ukwuu. Nke a rụrụ m ọrụ nke ọma na Ubuntu 20.04. Emelitere m Nginx nke ọma. Daalụ ọzọ.

3
0
Ga-ahụ n'anya gị echiche, biko okwu.x