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

openEuler2403编译安装Nginx

文章目录

  • openEuler2403编译安装Nginx
  • 一、前言
    • 1.简介
    • 2.环境
  • 二、正文
    • 1.安装依赖包
    • 2.编译安装
    • 3.常用指令
    • 4.常用模块
      • 1)http模块
      • 2)Stream 模块
      • 3)其他常用模块
      • 4)第三方模块
      • 5)示例

openEuler2403编译安装Nginx

一、前言

1.简介

nginx(“ engine x”)是一个 HTTP Web 服务器、反向代理、内容缓存、负载均衡器、TCP/UDP 代理服务器和邮件代理服务器

2.环境

Linux 发行版:openEuler-24.03-LTS-SP2-x86_64-dvd.iso

Nginx 版本:nginx-1.28.0

nginx 官网:https://dbeaver.io/

nginx-download:https://nginx.org/en/download.html

nginx入门和使用实践:https://blog.csdn.net/u011424614/article/details/107051875

openEuler常用操作指令:https://blog.csdn.net/u011424614/article/details/150942929

openEuler中LVM调整实现home与root分区空间平衡:https://blog.csdn.net/u011424614/article/details/150961763

openEuler安装部署JDK11:https://blog.csdn.net/u011424614/article/details/150961633

openEuler2403安装部署MySQL8:https://blog.csdn.net/u011424614/article/details/150966094

VirtualBox安装openEuler24.03:https://blog.csdn.net/u011424614/article/details/150725588

VMware安装openEuler24.03:https://blog.csdn.net/u011424614/article/details/150723134

二、正文

1.安装依赖包

dnf install pcre-devel zlib-devel openssl-devel

2.编译安装

  • NGINX 官网下载

在这里插入图片描述

  • 下载链接右击,可拷贝下载链接
# 创建下载目录,并进入目录
mkdir /opt/nginx && cd /opt/nginx# 下载软件包,如果 wget 无法下载,可使用浏览器或迅雷下载
wget https://nginx.org/download/nginx-1.28.0.tar.gz# 解压
tar -zxvf nginx-1.28.0.tar.gz#创建安装目录,并进入源码目录
mkdir /opt/nginx/install && cd nginx-1.28.0/# 配置安装路径,启用SSL和流模块
./configure --prefix=/opt/nginx/install --with-http_ssl_module --with-stream
# 编译安装
make && make install# 进入安装目录的sbin
cd /opt/nginx/install/sbin

3.常用指令

  • 启动和停止
# 启动 Nginx
./nginx
# 停止 Nginx(快速停止)
./nginx -s stop
# 优雅停止 Nginx(处理完当前请求后停止)
./nginx -s quit
# 重启 Nginx
./nginx -s reload 
# 重新打开日志文件
./nginx -s reopen
  • 配置管理
# 测试配置文件语法
./nginx -t
# 测试配置文件并显示详细信息
./nginx -T
# 指定配置文件启动,注意替换安装目录
./nginx -c /opt/nginx/install/conf/nginx.conf 
# 显示版本信息
./nginx -v
  • 进程管理
# 查看 Nginx 进程
ps aux | grep nginx 
# 查看 Nginx 监听端口 
netstat -tlnp | grep nginx 
ss -tlnp | grep nginx
# 杀死所有 Nginx 进程
pkill nginx
  • 日志(注意替换安装目录)
# 查看访问日志
tail -f /opt/nginx/install/logs/access.log  
# 查看错误日志 
tail -f /opt/nginx/install/logs/error.log 
# 实时监控日志
tail -f /opt/nginx/install/logs/access.log  | grep "pattern"
  • 防火墙
# 测试环境
systemctl stop firewalld.service
systemctl disable firewalld.service# 生产环境,建议使用
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
# 查看防火墙已开放端口
firewall-cmd --zone=public --list-ports
  • 测试访问:http://192.168.249.52/

在这里插入图片描述

4.常用模块

1)http模块

  • 基础功能模块
--with-http_ssl_module          # SSL/TLS 加密支持
--with-http_v2_module           # HTTP/2 支持 
--with-http_realip_module       # 获取真实客户端IP
--with-http_stub_status_module  # 状态监控统计
--with-http_gzip_static_module  # 预压缩文件传输
  • 认证和安全模块
--with-http_auth_request_module # 请求认证
--with-http_secure_link_module  # 安全链接
--with-http_sub_module          # 字符串替换
--with-http_addition_module     # 内容添加
  • 缓存和压缩模块
--with-http_gunzip_module       # gzip解压缩 
--with-http_gzip_static_module  # 静态gzip文件
--with-http_slice_module        # 大文件分片 

2)Stream 模块

  • TCP/UDP代理
--with-stream                   # Stream核心模块 
--with-stream_ssl_module        # Stream SSL支持
--with-stream_realip_module     # Stream真实IP获取

3)其他常用模块

--with-pcre                     # 正则表达式支持
--with-file-aio                 # 异步文件I/O
--with-threads                  # 线程池支持
--with-mail                     # 邮件代理模块 
--with-mail_ssl_module          # 邮件SSL支持

4)第三方模块

--add-module=/path/to/module    # 添加第三方模块 
--add-dynamic-module=/path/to/module  # 动态模块 

5)示例

  • 根据实际需求选择启用的模块,避免不必要的功能占用资源
./configure \
--prefix=/opt/nginx/install \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-stream \
--with-stream_ssl_module \
--with-threads \
--with-file-aio 
http://www.xdnf.cn/news/19519.html

相关文章:

  • 【期末复习】--软件工程
  • 苍穹外卖项目实战(日记十三)-记录实战教程及问题的解决方法-(day3-5) 修改菜品功能实现
  • C++ Bellman-Ford算法
  • 「数据获取」《中国住户调查年鉴》(2000-2024)(获取方式看绑定的资源)
  • # [特殊字符] 构建现代化黄金价格实时仪表盘:技术解析与实践
  • AI产品经理面试宝典第81天:RAG系统架构演进与面试核心要点解析
  • C++11新特性解析与应用
  • GPU 通用手册:裸机、Docker、K8s 环境实战宝典
  • Jetson AGX Orin平台R36.3.0版本1080P25fps MIPI相机图像采集异常调试记录
  • 在idea当中git的基础使用
  • 【公告】更新预告
  • 1.4 汽车的制动性
  • 面向对象六大设计原则(2.0详细版)
  • 永磁同步电机无速度算法--高频脉振方波注入法(测量轴系转子位置误差信号解耦处理)
  • Ansible 变量全解析与实践
  • MySQL DBA请注意 不要被Sleep会话蒙蔽了双眼
  • 【算法】124.二叉树中的最大路径和--通俗讲解
  • DeepSeek-V3.1 模型 API 新特性拆解:逆向 + 火山双渠道适配与推理模式智能切换指南
  • 保健品跨境电商:如何筑牢产品质量与安全防线?
  • 【推荐】Maye 更轻更简洁的快速启动工具【优化桌面】
  • AutoSar RTE介绍
  • FOC+MCU:重新定义吸尘器电机控制——高效、静音、智能的终极解决方案
  • LeetCode199. 二叉树的右视图 - 解题思路与实现
  • Linux Tun/Tap 多队列技术
  • CCache使用指南
  • 0901 C++的动态内存分配与回收
  • 全局网络,一目了然——OpManager可视化监控全景体验
  • AI 智能体架构中的协议设计三部曲:MCP → A2A → AG-UI
  • uniApp App 嵌入 H5 全流程:通信与跳转细节拆解
  • 嵌入式ARM程序高级调试技能:22.malloc free 的wrap实现,free支持 align free