Linux下Nginx编译安装过程详解

2023-10-30

一、Nginx介绍

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。
从2004年发布至今,凭借开源的力量,已经接近成熟与完善。
Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。支持FastCGI、SSL、Virtual Host、URL Rewrite、Gzip等功能。并且支持很多第三方的模块扩展。Nginx的稳定性、功能集、示例配置文件和低系统资源的消耗让他后来居上,在全球活跃的网站中有12.18%的使用比率,大约为2220万个网站。

二、Nginx源码下载

1.打开Nginx官网

Nginx官网
在这里插入图片描述

2.下载官网的源码包


# 下载文件为nginx-1.18.0 .tar  Nginx的源码包版本为1.18.0

三、Nginx源码安装

1.解压源码包

[root@node1 ~]# ll
total 1028
-rw-------. 1 root root    1608 Mar 19 22:27 anaconda-ks.cfg
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Desktop
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Documents
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Downloads
-rw-r--r--. 1 root root     378 May  2 20:57 dvd.repo
-rw-r--r--. 1 root root       0 May  5 12:47 file
-rw-r--r--. 1 root root    1763 Mar 19 22:32 initial-setup-ks.cfg
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Music
-rw-r--r--. 1 root root 1039530 May  8 13:19 nginx-1.18.0.tar.gz
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Pictures
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Public
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Templates
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Videos
[root@node1 ~]# tar -xf nginx-1.18.0.tar.gz 
[root@node1 ~]# ll
total 1028
-rw-------. 1 root    root       1608 Mar 19 22:27 anaconda-ks.cfg
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Desktop
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Documents
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Downloads
-rw-r--r--. 1 root    root        378 May  2 20:57 dvd.repo
-rw-r--r--. 1 root    root          0 May  5 12:47 file
-rw-r--r--. 1 root    root       1763 Mar 19 22:32 initial-setup-ks.cfg
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Music
drwxr-xr-x. 8 ansible ansible     158 Apr 21  2020 nginx-1.18.0
-rw-r--r--. 1 root    root    1039530 May  8 13:19 nginx-1.18.0.tar.gz
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Pictures
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Public
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Templates
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Videos

2.安装开发包组及环境

yum -y groupinstall "Development Tools"
[root@node1 ~]# yum -y install pcre-devel zlib-devel make
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
ansiable                                                                                                                            0.0  B/s |   0  B     00:00    
Failed to synchronize cache for repo 'ansiable', ignoring this repo.
Last metadata expiration check: 0:03:40 ago on Sat 08 May 2021 01:33:26 PM CST.
Package make-1:4.2.1-9.el8.x86_64 is already installed.
Dependencies resolved.
====================================================================================================================================================================
 Package                                 Arch                                Version                                      Repository                           Size
====================================================================================================================================================================
Installing:
 pcre-devel                              x86_64                              8.42-4.el8                                   BaseOS                              551 k
 zlib-devel                              x86_64                              1.2.11-10.el8                                BaseOS                               56 k
Installing dependencies:
 pcre-cpp                                x86_64                              8.42-4.el8                                   BaseOS                               47 k
 pcre-utf16                              x86_64                              8.42-4.el8                                   BaseOS                              195 k
 pcre-utf32                              x86_64                              8.42-4.el8                                   BaseOS                              186 k

Transaction Summary
====================================================================================================================================================================
Install  5 Packages

Total size: 1.0 M
Installed size: 2.7 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                            1/1 
  Installing       : pcre-utf32-8.42-4.el8.x86_64                                                                                                               1/5 
  Installing       : pcre-utf16-8.42-4.el8.x86_64                                                                                                               2/5 
  Installing       : pcre-cpp-8.42-4.el8.x86_64                                                                                                                 3/5 
  Installing       : pcre-devel-8.42-4.el8.x86_64                                                                                                               4/5 
  Installing       : zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5 
  Running scriptlet: zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5 
  Verifying        : pcre-cpp-8.42-4.el8.x86_64                                                                                                                 1/5 
  Verifying        : pcre-devel-8.42-4.el8.x86_64                                                                                                               2/5 
  Verifying        : pcre-utf16-8.42-4.el8.x86_64                                                                                                               3/5 
  Verifying        : pcre-utf32-8.42-4.el8.x86_64                                                                                                               4/5 
  Verifying        : zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5 
Installed products updated.

Installed:
  pcre-devel-8.42-4.el8.x86_64    zlib-devel-1.2.11-10.el8.x86_64    pcre-cpp-8.42-4.el8.x86_64    pcre-utf16-8.42-4.el8.x86_64    pcre-utf32-8.42-4.el8.x86_64   

Complete!

3.编译Nginx源码

 ./configure 
checking for OS
 + Linux 4.18.0-80.el8.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

make && make install

四、Nginx启动与检查


[root@node1 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful



[root@node1 sbin]# netstat -tunlp |grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      39424/nginx: master 
[root@node1 sbin]# ps -ef |grep nginx
root      39424      1  0 14:01 ?        00:00:00 nginx: master process ./nginx
nobody    39425  39424  0 14:01 ?        00:00:00 nginx: worker process
root      39462   1884  0 14:02 pts/0    00:00:00 grep --color=auto nginx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux下Nginx编译安装过程详解 的相关文章

  • 使用 Nginx 或 Apache 来提供动态内容? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 类似 wget 的 BitTorrent 客户端或库? [关闭]

    这个问题不太可能对任何未来的访客有帮助 它只与一个较小的地理区域 一个特定的时间点或一个非常狭窄的情况相关 通常不适用于全世界的互联网受众 为了帮助使这个问题更广泛地适用 访问帮助中心 help reopen questions 是否有任何
  • 在 Linux 2.6.21 (glibc 2.3.5) 上进行 ARP 和反向 ARP

    我需要在任意 IP 网络上存储对第三方设备的持久引用 其中设备的 IP 地址可能是静态的或由 DHCP 随机分配 我不控制网络上的设备 也不能依赖 DNS 和其他现有的或与设备一起使用的临时网络协议 所以我被指示使用硬件地址和 ARP 进行
  • 错误:从上游读取响应标头时上游过早关闭连接 [uWSGI/Django/NGINX]

    我目前在用户正在进行的查询中总是得到 502 它通常返回 872 行 在 MySQL 中运行需要 2 07 然而 它返回了大量信息 每一行包含很多东西 有任何想法吗 运行 Django tastypie Rest API Nginx 和 u
  • 如何从 C 文件更改终端中的目录

    如何从 C 程序更改将在终端上生效的目录 实际上不要告诉 system 函数或 chdir 函数 这些仅适用于 C 中的进程或子 shell 假设我正在从 bash shell 执行一个 C 程序 其进程 ID 为 10223 那么 我可以
  • 使用 linux perf 工具测量应用程序的 FLOP

    我想使用 perf Linux 性能计数器子系统的新命令行接口命令 来测量某些应用程序执行的浮点和算术运算的数量 出于测试目的 我使用了我创建的一个简单的虚拟应用程序 请参见下文 因为我找不到任何为测量 FP 和整数运算而定义的 perf
  • 操作系统崩溃的常见原因[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我有兴趣了解 操作系统崩溃 不限于Windows崩溃 最常见的技术原因 从操作系统编程的角度 有哪些 我正在寻找一个不像 打开太多应用
  • sed 仅最后一个匹配模式

    我想sed仅文本文件的最后一个匹配模式 输入文件 boy boy girl boy 输出文件 boy boy girl boys 一种方法是反转文件 仅替换第一个匹配项 然后再次反转 tac
  • 如何使用sprof?

    请举例说明 从邮件中找到here http sources redhat com ml libc alpha 2003 07 msg00029 html and here http sourceware org ml binutils 20
  • Snap-confine 具有提升的权限,并且不受限制,但应该受到限制。拒绝继续避免权限升级攻击

    我已经使用 snap 一段时间了 但最近升级后 当我尝试打开任何应用程序时 出现此错误 Snap confine has elevated permissions and is not confined but should be Refu
  • Nasm 打印到下一行

    我用 nasm Assembly 编写了以下程序 section text global start start Input variables mov edx inLen mov ecx inMsg mov ebx 1 mov eax 4
  • 有关 Linux 内存类型的问题

    关于Linux内存我有以下问题 我知道活动内存是最常访问的内存部分 但是有人可以解释一下 linux 如何考虑将内存位置用于活动内存或非活动内存 主动存储器由哪些部分组成 磁盘 文件缓存是否被视为活动内存的一部分 有什么区别Buffers
  • Alsa 带有来自调制解调器的 PCM 接口

    我有一个基于 imx28 CPU 的定制板 CPU 的串行端口连接到调制解调器的 PCM 输出 我必须为调制解调器的 PCM 接口开发一个驱动程序 使其成为 ALSA SoC 的一部分 您能指出内核树 中与我的设置重新组合的一些驱动程序吗
  • 如何删除树莓派的相机预览

    我在我的 raspberryPi 上安装了 SimpleCv 并安装了用于使用相机板的驱动程序 uv4l 驱动程序 现在我想使用它 当我在 simpleCV shell Camera 0 getImage save foo jpg 上键入时
  • /proc/PID 文件格式

    我想从中检索一些流程信息 proc目录 我的问题如下 中的文件是否有标准格式 proc PID 例如 有这个proc PID status文件与Name t ProcName在第一行 我可以在其他地方用空格代替这个文件吗 t或者类似的东西
  • Docker DNS 设置

    我尝试使用自定义网络和 dos 设置创建 docker 容器 docker网络创建 driver bridge opt com docker network bridge enable ip masquerade true opt com
  • 编写多个mysql脚本

    是否可以在复合脚本中包含其他 mysql 脚本 理想情况下 我不想为包含的脚本创建存储过程 对于较大的项目 我想分层维护几个较小的脚本 然后根据需要组合它们 但现在 我很乐意学习如何包含其他脚本 source是一个内置命令 您可以在 MyS
  • 远程linux服务器到远程linux服务器大型稀疏文件复制 - 如何?

    我有两台 CentOS 5 4 服务器 每台服务器上都安装了 VMware Server 假设我始终对 vmware 虚拟机使用稀疏文件 将虚拟机文件从一台服务器复制到另一台服务器的最可靠 最快速的方法是什么 虚拟机的文件复制起来很痛苦 因
  • 如何仅将整个嵌套目录中的头文件复制到另一个目录,在复制到新文件夹后保持相同的层次结构

    我有一个目录 其中有很多头文件 h 和其他 o 和 c 文件以及其他文件 这个目录里面有很多嵌套的目录 我只想将头文件复制到一个单独的目录 并在新目录中保留相同的结构 cp rf oldDirectory newDirectory将复制所有
  • Windows 与 Linux 文本文件读取

    问题是 我最近从 Windows 切换到 Ubuntu 我的一些用于分析数据文件的 python 脚本给了我错误 我不确定如何正确解决 我当前仪器的数据文件输出如下 Header 有关仪器等的各种信息 Data 状态 代码 温度 字段等 0

随机推荐

  • HarmonyOS 鸿蒙

    HarmonyOS是一款 面向未来 面向全场景 移动办公 运动健康 社交通信 媒体娱乐等 的分布式操作系统 在传统的单设备系统能力的基础上 HarmonyOS提出了基于同一套系统能力 适配多种终端形态的分布式理念 能够支持多种终端设备 通知
  • 4-0 特征选择简述

    第4章 特征选择 4 0 特征选择简述 请参考 数据准备和特征工程 中的相关章节 调试如下代码 import pandas as pd df wine pd read csv home aistudio data data20527 win
  • [踩坑记录] Unresolved reference: viewModels() 和 Unresolved reference: activityViewModels()

    解决无法使用by viewModels by activityViewModels 安卓开发过程使用kotlin开发LiveData和ViewModel时 有时候会遇到 Unresolved reference viewModels Unr
  • OpenCV-Python图像颜色变换

    给图像添加颜色 在使用OpenCV操作图像时 有时候需要给图像添加不同的颜色 以达到不同的风格效果 这里介绍的主要是opencv中的cv applyColorMap 函数 给图像应用颜色函数cv applyColorMap src colo
  • SpringMVC复习总结

    一 SpringMVC简介 1 什么是SpringMVC MVC是什么 MVC是一种软件架构的思想 将软件按照模型 视图 控制器来划分 M Model 模型层 指工程中的JavaBean 作用是处理数据 JavaBean分为两类 一类称为实
  • vue之web3.js开发之错误:Uncaught (in promise) TypeError: Cannot read property 'node

    这个问题的意思就是找不到node节点的意思 init web3 1 0 version this web3 new Web3 Web3 givenProvider new Web3 providers HttpProvider http 1
  • C# 重写WndProc 消息循环

    重写WndProc方法来处理 Windows 消息 处理 Windows 消息 在开发winForm时 常常要处理Windows消息 可以重写WndProc来实现 常见代码如下 using System using System Drawi
  • mac m1 mysqlworkbench8 Unknown table ‘COLUMN_STATISTICS‘

    原因 本地mysql版本是8 远程是mariaDb 10 版本不匹配导致报错 仔细看mysqlworkbench8 0导出时的错误信息 有mysqldump的具体路径 mac os m1 ventura系统 具体位置是这里 Applicat
  • 获取当前季度、前N季度、判断时间是否超出该季度

    获取当前季度 前N个季度的值 指定时间和季度 来判断该事件是否超出了该季度 ClassName QuarterUtil Description 季度工具类 public class QuarterUtil private static fi
  • Prometheus部署

    目录 一 部署prometheus 1 环境准备工作 2 普罗米修斯的部署 2 1 上传prometheus到 opt目录中 解压 2 2 修改配置文件 2 3 配置系统启动文件 设置开机自启 2 4 开启prometheus 并访问网页验
  • maven install时报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile

    首先检查父项目 子项目的jdk版本是否一致 编码格式是否一致 我的问题就错在了编码格式上 父项目用的是UTF 8 子项目新建的 默认GBK 这时 使用maven install命令出错 提示 INFO pims core Maven Web
  • cycleGAN有matlab代码吗,CycleGAN的代码组成

    train py 是通用训练脚本 它为许多模型 可选的模型比如 pix2pix cyclegan colorization 和不同的数据集服务 可选的数据集模式包括 aligned unaligned single colorization
  • kdj买卖指标公式源码_通达信指标公式源码买卖操盘指标副图源码

    做价值的传播者 一路同行 一起成长 问题 怎样才能每天都收到这类文章 答案 只需点击上方 通达信公式指标 VAR1 CLOSE gt REF CLOSE 1 AND CLOSE gt REF CLOSE 2 VAR2 REF VAR1 1
  • docker方式部署redis

    docker 安装redis 拉去镜像 docker pull redis Using default tag latest latest Pulling from library redis 8ec398bc0356 Pull compl
  • java方法引用的使用详解

    使用情境 当要传递给Lambda体的操作 已经有实现的方法了 可以使用方法引用 方法引用的本质 本质上就是Lambda表达式 而Lambda表达式作为函数式接口的实例 所以 方法引用 也是函数式接口的实例 使用格式 类 或对象 方法名 具体
  • Layui官网文档备份, Layui文档站点,LayuiAdmin

    layui文档在线查看 镜像 https www layuion com LayuiAdmin v2 5 6 iframe版 后台管理模板 有需求的 评论区留言1
  • 【QT】:QT实现关联和解决关联

    connect实现关联 disconnect实现解除关联 思路 1 一个可用 另一个就不可用 2 关联和解除关联 代码在cpp文件里面 void Widget on pushButton 6 clicked connect ui gt li
  • anylabeling安装与使用说明

    文章目录 一 anylabeling说明 二 安装教程 1 可执行程序方式 2 python程序 一 anylabeling说明 官网 https anylabeling nrl ai docs 该工具作为一个具有Segment Anyth
  • 西门子锂电池项目,1500安全型PLC程序

    西门子锂电池项目 1500安全型PLC程序 包含对接雅马哈机器人 视觉 库卡机器人 MES通信程序块 由STL语言和LAD编写7678621367452135油腻的肥宅仔
  • Linux下Nginx编译安装过程详解

    Linux下Nginx编译安装过程详解 一 Nginx介绍 二 Nginx源码下载 1 打开Nginx官网 2 下载官网的源码包 三 Nginx源码安装 1 解压源码包 2 安装开发包组及环境 3 编译Nginx源码 四 Nginx启动与检