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

Nginx Ubuntu vs CentOS 常见对照表

功能 Ubuntu/Debian 系列 CentOS/RHEL 系列
安装命令 sudo apt update && sudo apt install nginx -y sudo yum install nginx -y 或 sudo 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/)
相关推荐
New农民工12 分钟前
倒立摆训练秘籍:理解训练参数
学习
L@ncor1 小时前
第五章 基于低代码平台的智能体搭建 · 学习笔记(Coze / Dify / FastGPT / n8n)
笔记·学习·低代码·agent·prompt工程
知潮网1 小时前
被嫌弃的五仁月饼,一吨千元在养猪场翻了身
笔记
2601_960631231 小时前
中药前处理及提取的工艺环节与技术要点
笔记
2601_965384261 小时前
口腔黏膜清洁中的几何约束与流体动力学边界层问题分析
经验分享·笔记
迪丽热爱1 小时前
多媒体应用20-903(补)
学习
Huangjin007_1 小时前
【Linux 系统篇(二十五)】文件(二) 系统文件I/O详解
linux·运维·服务器
2601_962381131 小时前
历史视频朝代更替动效怎么做?把 AE 关键帧换成 AI 分镜动画的实战拆解
人工智能·nginx·音视频
微小冷2 小时前
Mermaid画甘特图
运维·markdown·甘特图·mermaid·时间图
一米阳光86612 小时前
软考高级【信息系统项目管理师】高项重要考点(9)组织 助你顺利上岸!
笔记·职场发展·软考·高项·信息系统项目管理师·高级职称