当前位置: 首页 > article >正文

Nginx:安装部署和升级(平滑升级)

在这里插入图片描述

安装 Nginx

在 Ubuntu 上安装 Nginx

步骤 1:更新软件包列表
首先,你需要确保系统的软件包列表是最新的。打开终端并运行以下命令:

sudo apt update

步骤 2:安装 Nginx
接下来,使用 apt 包管理器来安装 Nginx:

sudo apt install nginx

步骤 3:启动 Nginx
安装完成后,启动 Nginx 服务:

sudo systemctl start nginx

步骤 4:设置开机自启
为了让 Nginx 在系统启动时自动运行,你可以设置它为开机自启:

sudo systemctl enable nginx

步骤 5:验证安装
最后,通过访问服务器的 IP 地址或域名来验证 Nginx 是否正确安装并运行。你应该会看到默认的 Nginx 欢迎页面。

在 CentOS 上安装 Nginx

步骤 1:更新软件包列表
同样地,先更新系统的软件包列表:

sudo yum update

步骤 2:安装 EPEL 仓库
CentOS 默认的官方仓库可能不包含最新的 Nginx 版本,因此需要添加 EPEL(Extra Packages for Enterprise Linux)仓库:

sudo yum install epel-release

步骤 3:安装 Nginx
现在可以使用 yum 安装 Nginx:

sudo yum install nginx

步骤 4:启动 Nginx
安装完成后,启动 Nginx 服务:

sudo systemctl start nginx

步骤 5:设置开机自启
让 Nginx 在系统启动时自动运行:

sudo systemctl enable nginx

步骤 6:防火墙配置(如果启用)
如果你启用了防火墙(firewalld),需要允许 HTTP 和 HTTPS 流量:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --

http://www.kler.cn/a/467714.html

相关文章:

  • js-19-手写题
  • 软件逆向之标志位
  • 【测试工具】 Postman 基本使用
  • 【Linux】调度优先级(谦让度)
  • spring、spring boot、Springmvc 的区别和关系
  • k8s集群部署 - Dashboard v2.7
  • MySQL 8 主从同步配置(Master-Slave Replication)
  • ESP32移植Openharmony外设篇(7)土壤湿度传感器YL-69
  • Python进阶-08-继承性
  • 编译 C++ 程序:分离与保留调试信息以支持 GDB 对 Core 文件的调试
  • 如何自行解锁 ATamp;T 手机
  • UE5 slate创建SDockTab标签页的过程理解
  • Megatron - LM 怎么进行模型切分的,怎么匹配服务器的
  • 量子力学复习
  • STM32学习之MPU6050芯片 及 软件I2C读写MPU6050实验
  • linux命令行连接Postgresql常用命令
  • 【高阶数据结构】哈希表封装unordered_map、unordered_set
  • 【论文阅读】Anchor-based fast spectral ensemble clustering
  • 微服务保护—Sentinel快速入门+微服务整合 示例: 黑马商城
  • 我用AI学Android Jetpack Compose之Jetpack Compose学习路径篇