Nginx的源码编译

一:Nginx 介绍

Nginx是免费的、开源的、高性能的HTTP和反向代理服务器、邮件代理服务器、以及TCP/UDP代理服务 器 解决C10K问题(10K Connections)

Nginx功能:静态的web资源服务器html,图片,js,css,txt等,http/https协议的反向代理,结合FastCGI/uWSGI/SCGI等协议反向代理,动态资源请求 tcp/udp协议的请求转发(反向代理) ,imap4/pop3协议的反向代理。

二:Nginx 进程间通信

工作进程是由主进程生成的,主进程使用fork()函数,在Nginx服务器启动过程中主进程根据配置文件决 定启动工作进程的数量,然后建立一张全局的工作表用于存放当前未退出的所有的工作进程,主进程生 成工作进程后会将新生成的工作进程加入到工作进程表中,并建立一个单向的管道并将其传递给工作进 程,该管道与普通的管道不同,它是由主进程指向工作进程的单向通道,包含了主进程向工作进程发出 的指令、工作进程ID、工作进程在工作进程表中的索引和必要的文件描述符等信息。

主进程与外界通过信号机制进行通信,当接收到需要处理的信号时,它通过管道向相关的工作进程发送 正确的指令,每个工作进程都有能力捕获管道中的可读事件,当管道中有可读事件的时候,工作进程就 会从管道中读取并解析指令,然后采取相应的执行动作,这样就完成了主进程与工作进程的交互。

三:Nginx 编译安装

获取Nginx的安装包

root@localhost \~\] wget https://nginx.org/download/nginx-1.26.2.tar.gz 解压压缩包 \[root@localhost \~\]# tar zxf nginx-1.26.2.tar.gz ![](https://i-blog.csdnimg.cn/direct/2a18d406ce5144ffa4e18b69bb051f7e.png) 安装C语言编辑器 \[root@localhost nginx-1.26.2\]# yum install gcc ![](https://i-blog.csdnimg.cn/direct/b064251d43dc404a954ee2d5be6cc71e.png) 切换目录底下增加模块,指定安装功能 \[root@localhost \~\]# cd nginx-1.26.2/ \[root@localhost nginx-1.26.2\]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_module ![](https://i-blog.csdnimg.cn/direct/99277393946a45d0aca66d794c6ff1a7.png) ![](https://i-blog.csdnimg.cn/direct/625dcdaa625147c0aa9051000da06aa5.png) 缺少PCRE安装包寻找安装包 \[root@localhost nginx-1.26.2\]# yum search PCRE ![](https://i-blog.csdnimg.cn/direct/1e79343e73de48b0bc532fa2d714078b.png) \[root@localhost nginx-1.26.2\]# yum install pcre-devel.x86_64 ![](https://i-blog.csdnimg.cn/direct/19c7a736b7da4021aa66ede275137491.png) \[root@localhost nginx-1.26.2\]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_module 再次检测发现还缺失OpenSSL包 ![](https://i-blog.csdnimg.cn/direct/1687712062fe4c7b8573b1ccd23af7d5.png) \[root@localhost nginx-1.26.2\]# yum search OpenSSL ![](https://i-blog.csdnimg.cn/direct/a6e0301b6d124cd2a49988c005c917c9.png) \[root@localhost nginx-1.26.2\]# yum install openssl-devel.x86_64 ![](https://i-blog.csdnimg.cn/direct/943a23a163f24205ad053329132c98f6.png) \[root@localhost nginx-1.26.2\]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_module 再再次检测发现还缺失zlib包 ![](https://i-blog.csdnimg.cn/direct/b6eba758cca24279b54c47dd30d5e040.png) \[root@localhost nginx-1.26.2\]# yum install zlib-devel.x86_64![](https://i-blog.csdnimg.cn/direct/b54a7c4fa71b4e19bf3663986c848fe3.png)![](https://i-blog.csdnimg.cn/direct/feb0a582ec7f42e1b865d2ea0de1c747.png) 完成Nginx的源码编译 同时生成文件Makefile和objs目录 ![](https://i-blog.csdnimg.cn/direct/e361bfa70ed1446cb385f3a8e8025da0.png)

相关推荐
消失的旧时光-19437 分钟前
Linux 入门核心命令清单(工程版)
linux·运维·服务器
艾莉丝努力练剑14 分钟前
【Linux:文件】Ext系列文件系统(初阶)
大数据·linux·运维·服务器·c++·人工智能·算法
小天源18 分钟前
Cacti在Debian/Ubuntu中安装及其使用
运维·ubuntu·debian·cacti
Trouvaille ~40 分钟前
【Linux】TCP Socket编程实战(一):API详解与单连接Echo Server
linux·运维·服务器·网络·c++·tcp/ip·socket
芷栀夏1 小时前
深度解析 CANN 异构计算架构:基于 ACL API 的算子调用实战
运维·人工智能·开源·cann
全栈工程师修炼指南1 小时前
Nginx | stream 四层反向代理:SSL、PREREAD 阶段模块指令浅析与实践
运维·网络·网络协议·nginx·ssl
威迪斯特2 小时前
CentOS图形化操作界面:理论解析与实践指南
linux·运维·centos·组件·图形化·桌面·xserver
一方热衷.2 小时前
在线安装对应版本NVIDIA驱动
linux·运维·服务器
独自归家的兔2 小时前
ubuntu系统安装dbswitch教程 - 备份本地数据到远程服务器
linux·运维·ubuntu
ONE_SIX_MIX2 小时前
ubuntu 24.04 用rdp连接,桌面黑屏问题,解决
linux·运维·ubuntu