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/
相关推荐
无级程序员24 分钟前
centos7 安装 llvm-toolset-7-clang出错的问题解决
linux·centos
龙文浩_37 分钟前
Attention Mechanism: From Theory to Code
人工智能·深度学习·神经网络·学习·自然语言处理
赛博云推-Twitter热门霸屏工具1 小时前
Twitter运营完整流程:从0到引流获客全流程拆解(2026)
运维·安全·自动化·媒体·twitter
守护安静星空1 小时前
esp32开发笔记-工程搭建
笔记·单片机·嵌入式硬件·物联网·visual studio code
CHHC18801 小时前
NetCore树莓派桌面应用程序
linux·运维·服务器
ljt27249606611 小时前
Compose笔记(七十七)--视频录制
笔记·android jetpack
帮我吧智能服务平台2 小时前
装备制造智能制造升级:远程运维与智能服务如何保障产线OEE
运维·服务器·制造
w6100104662 小时前
cka-2026-cri-dockerd
运维·k8s·cka
爱上好庆祝2 小时前
svg图片
前端·css·学习·html·css3
橘子编程3 小时前
JavaScript与TypeScript终极指南
javascript·ubuntu·typescript