Caching

Estimated reading: 2 minutes 4 views

Cài đặt phiên bản mới nhất của Nginx trên ubuntu

Update Ubuntu :

sudo apt update && sudo apt upgrade -y

Gỡ bỏ cài đặt cấu hình cũ của Nginx (nếu có):

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

Cài đặt và nâng cấp Nginx Repository

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

Tải về và cài Nginx GPG key để xác nhận gói

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

Xác thực key :

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

Import Nginx stable Repository :

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

Import Nginx Mainline Repository:

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

Cài đặt gói APT hướng đến phiên bản Nginx hoặc các phiên bản mặc định khác của PPA’s :

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

Cải đặt Nginx :

sudo apt update
sudo apt install nginx

Khởi động của nginx :

systemctl start nginx
systemctl enable nginx

Kiểm tra hoạt động của nginx :

systemctl status nginx
nginx -t

Vậy là đã hoàn thành !

Leave a Comment

Share this Doc

Caching

Or copy link

CONTENTS