Nginx Ubuntu vs CentOS 常用命令对照表---详解笔记

Nginx Ubuntu vs CentOS 常见对照表

功能 Ubuntu/Debian 系列 CentOS/RHEL 系列
安装命令 sudo apt update && sudo apt install nginx -y sudo yum install nginx -ysudo dnf install nginx -y
启动服务 sudo systemctl start nginx sudo systemctl start nginx
停止服务 sudo systemctl stop nginx sudo systemctl stop nginx
重启服务 sudo systemctl restart nginx sudo systemctl restart nginx
查看状态 sudo systemctl status nginx sudo systemctl status nginx
开机自启 sudo systemctl enable nginx sudo systemctl enable nginx
主配置文件 /etc/nginx/nginx.conf /etc/nginx/nginx.conf
虚拟主机配置目录 /etc/nginx/sites-available/ + /etc/nginx/sites-enabled/(通过软链接启用) /etc/nginx/conf.d/(直接放 .conf 文件)
默认网页目录 /var/www/html/ /usr/share/nginx/html/
测试配置是否正确 sudo nginx -t sudo nginx -t
防火墙放行 HTTP/HTTPS sudo ufw allow 'Nginx Full' sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reload
日志文件路径 访问日志:/var/log/nginx/access.log 错误日志:/var/log/nginx/error.log 访问日志:/var/log/nginx/access.log 错误日志:/var/log/nginx/error.log

重点记住三点差异

  1. 安装命令apt vs yum/dnf
  2. 站点配置目录 (Ubuntu 用 sites-available/ + sites-enabled/,CentOS 用 conf.d/
  3. 网页目录 (Ubuntu 在 /var/www/html/,CentOS 在 /usr/share/nginx/html/
相关推荐
梦想很大很大11 小时前
拒绝“盲猜式”调优:在 Go Gin 项目中落地 OpenTelemetry 链路追踪
运维·后端·go
Sinclair12 小时前
内网服务器离线安装 Nginx+PHP+MySQL 的方法
运维
叶落阁主12 小时前
Tailscale 完全指南:从入门到私有 DERP 部署
运维·安全·远程工作
十二74020 小时前
前端缓存踩坑实录:从版本号管理到自动化构建
前端·javascript·nginx
齐生120 小时前
iOS 知识点 - IAP 是怎样的?
笔记
字节逆旅1 天前
ubuntu应用深度守护
ubuntu
tingshuo29171 天前
D006 【模板】并查集
笔记
可观测性用观测云2 天前
云原生网关 Ingress-Nginx 链路追踪实战:OpenTelemetry 采集与观测云集成方案
nginx·kubernetes
甲鱼9292 天前
MySQL 实战手记:日志管理与主从复制搭建全指南
运维
tingshuo29172 天前
S001 【模板】从前缀函数到KMP应用 字符串匹配 字符串周期
笔记