尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

企业级Nginx安装部署

企业级Nginx安装部署
📅 发布时间:2026/6/26 11:34:13

企业级Nginx安装部署

1. Nginx 安装方式

  • 编译安装:使用源码,根据企业业务需求,需要什么功能,编译时添加什么模块,但是安装过程较为繁琐
  • 自动化安装:配置好安装源,直接通过自动化工具安装即可
  • 二进制安装:解压即用,直接下载已经编译好的可执行文件

2. Nginx 编译安装

2.1 下载源码包

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

本文使用 nginx-1.26.3.tar.gz

2.2 编译安装

# 安装依赖包
$ sudo yum install -y gcc pcre pcre-devel openssl openssl-devel zlib zlib-devel$ tar -zxvf nginx-1.26.3.tar.gz
$ cd nginx-1.26.3# 编译
$ ./configure \--prefix=/usr/local/nginx \ # 设置 nginx 安装目录--sbin-path=/bin/ \ # nginx 命令存放目录--user=nginx \ # 设置运行 nginx 服务的用户--group=nginx \ # 设置运行 nginx 服务的组--with-http_ssl_module \ # 使用 --with 添加了 6 个模块--with-http_stub_status_module \--with-http_gzip_static_module \--with-http_v2_module \--with-stream \--with-stream_ssl_module$ make
$ sudo make install# 测试
$ nginx -v
nginx version: nginx/1.26.3
$ nginx -V
nginx version: nginx/1.26.3
built by gcc 11.4.1 20231218 (Red Hat 11.4.1-3) (GCC) 
built with OpenSSL 3.5.1 1 Jul 2025
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/bin/ --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_v2_module --with-stream --with-stream_ssl_module# 创建 nginx 用户
$ sudo useradd nginx -M -s /sbin/nologin# 启动 Nginx 服务
$ nginx# 验证
$ netstat -lntup | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      28787/nginx: master$ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.3 编译常见报错

# 报错 1 ./configure: error:C compiler cc is not found 
# 报错 1 解决办法
$ sudo yum install -y gcc# 报错 2 ./configure: error: the HTTP rewrite module requires the PCRE library.
# You can either disable the module by using --without-http_rewrite_module option, 
# or install the PCRE library into the system, 
# or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option. 
# 报错 2 解决办法
$ sudo yum install -y pcre pcre-devel# 报错 3 ./configure: error: SSL modules require the OpenSSL library.
# You can either do not enable the modules, or install the OpenSSL libraryinto the system,
# or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=<path> option.
# 报错 3 解决办法
$ sudo yum install -y openssl openssl-devel# 报错 4 ./configure: error: the HTTP gzip module requires the zlib library.
# You can either disable the module by using --without-http_gzip_module
# option, or install the zlib library into the system, or build the zlib library
# statically from the source with nginx by using --with-zlib=<path> option.
# 报错 4 解决办法
$ sudo yum install -y zlib zlib-devel

3. YUM 安装 Nginx

https://nginx.org/en/linux_packages.html#RHEL

$ sudo yum install yum-utils$ sudo tee /etc/yum.repos.d/nginx.repo > /dev/null << 'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF# 如果只想安装稳定版本,则不要执行这条命令
$ sudo yum-config-manager --enable nginx-mainline# 关闭 mainline 源
$ sudo yum-config-manager --disable nginx-mainline$ sudo yum install nginx -y$ systemctl enable nginx --now$ sudo ln -s /usr/sbin/nginx /usr/bin/nginx

相关新闻

  • 2025 年 10 月门窗十大品牌综合实力权威推荐榜单,精准检测与稳定性能兼具的行业优选解析
  • 2025 年 10 月门窗十大品牌综合实力权威推荐榜单,聚焦高端定制需求与全案交付能力
  • 力扣 第473场周赛(A~D)

最新新闻

  • MC9S08GW64 PCounter模块:旋转编码器信号处理与PWM生成的硬件解决方案
  • MusicFree插件全解析:三步骤打造你的专属跨平台音乐播放器
  • 开关稳压器PCB布局与热设计实战:从理论计算到工程实现
  • 三维波动方程加权Strichartz估计与强惠更斯原理详解
  • HCS08 CPU架构深度解析:从寄存器寻址到嵌入式实战优化
  • MCP16301/H峰值电流模式降压DC-DC转换器设计实战:从宽压输入到PCB布局

日新闻

  • Qwen2.5-Turbo百万上下文实战指南:百炼平台长文本处理全解析
  • 怎么监控对标账号更新,2026年作者监控工作流,5款深度对比
  • EdgeRemover:专业级Windows Edge浏览器管理工具,彻底解决顽固软件卸载难题

周新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号