# 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/