# Open Terminal (or connect via SSH)
# Ensure you have all of the prerequisites installed:
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
# Import the nginx signing key for apt:
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
# Create a sources .list file for apt:
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
# Pin the repository to ensure the nginx packages are installed instead of the Ubuntu-provided packages:
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99-nginx
# Update apt:
sudo apt update
# Install nginx:
sudo apt install nginx
Ubuntu20.04 apt安装1.20以上最新版本的nginx
最新推荐文章于 2024-05-09 15:35:22 发布