如何在 Ubuntu 22.04 上安裝、配置、使用 Nginx?-阿里云開發者社區
更新應用
sudo apt updatesudo apt upgrade
檢查必要依賴并安裝
sudo apt install -y curl gnupg2 ca-certificates lsb-release
安裝nginx
sudo apt install -y nginx# 啟動nginx
sudo systemctl start nginx# 開機自啟
sudo systemctl enable nginx
管理Nginx服務
sudo systemctl start nginxsudo systemctl stop nginxsudo systemctl restart nginxsudo systemctl status nginxsudo tail -f /var/log/nginx/error.log
Nginx配置
sudo nano /etc/nginx/sites-available/mywebsite# 重新加載配置
sudo systemctl reload nginx