# Ubuntu
sudo apt install nginx-light # 精簡版
# CentOS
sudo yum install nginx
#啟動并設置開機自啟
sudo systemctl daemon-reload
sudo systemctl start nginx
sudo systemctl enable nginx
#驗證安裝
nginx -v
curl -I 127.0.0.1
#常用命令:
# 重新加載配置
sudo systemctl reload nginx
# 檢查配置語法
sudo nginx -t
# 查看運行狀態
sudo systemctl status nginx
配置文件位置:
-
主配置:
/etc/nginx/nginx.conf
-
站點配置:
/etc/nginx/conf.d/