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

重识Nginx - 02 手把手教你编译适合自己的nginx 1.22.0

文章目录

  • 编译Nginx
    • 下载nginx 1.22.0
    • step 2 解压
    • 编译 (这里我们只指定 prefix,其他默认 )
    • make 编译
    • make install 安装
  • Configure的命令参数

在这里插入图片描述

编译Nginx

在这里插入图片描述

下载nginx 1.22.0

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

在这里插入图片描述

复制链接地址 ,下载 1.22.0


[root@VM-0-7-centos ng]# wget  https://nginx.org/download/nginx-1.22.0.tar.gz
--2022-09-25 23:23:40--  https://nginx.org/download/nginx-1.22.0.tar.gz
Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073322 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.22.0.tar.gz’

nginx-1.22.0.tar.gz                100%[===============================================================>]   1.02M  1.01MB/s    in 1.0s

2022-09-25 23:23:42 (1.01 MB/s) - ‘nginx-1.22.0.tar.gz’ saved [1073322/1073322]

[root@VM-0-7-centos ng]#


step 2 解压

[root@VM-0-7-centos ng]# tar -xvzf nginx-1.22.0.tar.gz

[root@VM-0-7-centos ng]# cd nginx-1.22.0/
[root@VM-0-7-centos nginx-1.22.0]# ll
total 824
drwxr-xr-x 6 1001 1001   4096 Sep 25 23:26 auto
-rw-r--r-- 1 1001 1001 317070 May 24 07:59 CHANGES
-rw-r--r-- 1 1001 1001 484445 May 24 07:59 CHANGES.ru
drwxr-xr-x 2 1001 1001   4096 Sep 25 23:26 conf
-rwxr-xr-x 1 1001 1001   2590 May 24 07:59 configure
drwxr-xr-x 4 1001 1001   4096 Sep 25 23:26 contrib
drwxr-xr-x 2 1001 1001   4096 Sep 25 23:26 html
-rw-r--r-- 1 1001 1001   1397 May 24 07:59 LICENSE
drwxr-xr-x 2 1001 1001   4096 Sep 25 23:26 man
-rw-r--r-- 1 1001 1001     49 May 24 07:59 README
drwxr-xr-x 9 1001 1001   4096 Sep 25 23:26 src

编译 (这里我们只指定 prefix,其他默认 )

[root@VM-0-7-centos nginx-1.22.0]# ./configure --prefix=/root/ng/artisan_ng
checking for OS
 + Linux 4.18.0-348.7.1.el8_5.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
checking for gcc -pipe switch ... found
.....
.....
creating objs/Makefile

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

  nginx path prefix: "/root/ng/artisan_ng"
  nginx binary file: "/root/ng/artisan_ng/sbin/nginx"
  nginx modules path: "/root/ng/artisan_ng/modules"
  nginx configuration prefix: "/root/ng/artisan_ng/conf"
  nginx configuration file: "/root/ng/artisan_ng/conf/nginx.conf"
  nginx pid file: "/root/ng/artisan_ng/logs/nginx.pid"
  nginx error log file: "/root/ng/artisan_ng/logs/error.log"
  nginx http access log file: "/root/ng/artisan_ng/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"

[root@VM-0-7-centos nginx-1.22.0]#

搞完这个以后,你会发现在ng的解压目录下多了个一目录叫 objs

在这里插入图片描述


make 编译


[root@VM-0-7-centos nginx-1.22.0]# pwd
/root/ng/nginx-1.22.0
[root@VM-0-7-centos nginx-1.22.0]#
[root@VM-0-7-centos nginx-1.22.0]#
[root@VM-0-7-centos nginx-1.22.0]# make


make install 安装


[root@VM-0-7-centos nginx-1.22.0]# make install
make -f objs/Makefile install
make[1]: Entering directory '/root/ng/nginx-1.22.0'
test -d '/root/ng/artisan_ng' || mkdir -p '/root/ng/artisan_ng'
test -d '/root/ng/artisan_ng/sbin' \
        || mkdir -p '/root/ng/artisan_ng/sbin'
test ! -f '/root/ng/artisan_ng/sbin/nginx' \
        || mv '/root/ng/artisan_ng/sbin/nginx' \
                '/root/ng/artisan_ng/sbin/nginx.old'
cp objs/nginx '/root/ng/artisan_ng/sbin/nginx'
test -d '/root/ng/artisan_ng/conf' \
        || mkdir -p '/root/ng/artisan_ng/conf'
cp conf/koi-win '/root/ng/artisan_ng/conf'
cp conf/koi-utf '/root/ng/artisan_ng/conf'
cp conf/win-utf '/root/ng/artisan_ng/conf'
test -f '/root/ng/artisan_ng/conf/mime.types' \
        || cp conf/mime.types '/root/ng/artisan_ng/conf'
cp conf/mime.types '/root/ng/artisan_ng/conf/mime.types.default'
test -f '/root/ng/artisan_ng/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/root/ng/artisan_ng/conf'
cp conf/fastcgi_params \
        '/root/ng/artisan_ng/conf/fastcgi_params.default'
test -f '/root/ng/artisan_ng/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/root/ng/artisan_ng/conf'
cp conf/fastcgi.conf '/root/ng/artisan_ng/conf/fastcgi.conf.default'
test -f '/root/ng/artisan_ng/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/root/ng/artisan_ng/conf'
cp conf/uwsgi_params \
        '/root/ng/artisan_ng/conf/uwsgi_params.default'
test -f '/root/ng/artisan_ng/conf/scgi_params' \
        || cp conf/scgi_params '/root/ng/artisan_ng/conf'
cp conf/scgi_params \
        '/root/ng/artisan_ng/conf/scgi_params.default'
test -f '/root/ng/artisan_ng/conf/nginx.conf' \
        || cp conf/nginx.conf '/root/ng/artisan_ng/conf/nginx.conf'
cp conf/nginx.conf '/root/ng/artisan_ng/conf/nginx.conf.default'
test -d '/root/ng/artisan_ng/logs' \
        || mkdir -p '/root/ng/artisan_ng/logs'
test -d '/root/ng/artisan_ng/logs' \
        || mkdir -p '/root/ng/artisan_ng/logs'
test -d '/root/ng/artisan_ng/html' \
        || cp -R html '/root/ng/artisan_ng'
test -d '/root/ng/artisan_ng/logs' \
        || mkdir -p '/root/ng/artisan_ng/logs'
make[1]: Leaving directory '/root/ng/nginx-1.22.0'
[root@VM-0-7-centos nginx-1.22.0]#

然后就可以到 prefix目录下 ,找编译好的ng去了


[root@VM-0-7-centos nginx-1.22.0]# cd /root/ng/artisan_ng
[root@VM-0-7-centos artisan_ng]# ll
total 16
drwxr-xr-x 2 root root 4096 Sep 26 00:14 conf
drwxr-xr-x 2 root root 4096 Sep 26 00:14 html
drwxr-xr-x 2 root root 4096 Sep 26 00:14 logs
drwxr-xr-x 2 root root 4096 Sep 26 00:14 sbin
[root@VM-0-7-centos artisan_ng]#
[root@VM-0-7-centos artisan_ng]# cd sbin/
[root@VM-0-7-centos sbin]# ll
total 4936
-rwxr-xr-x 1 root root 5054352 Sep 26 00:14 nginx
[root@VM-0-7-centos sbin]# ./nginx -v
nginx version: nginx/1.22.0
[root@VM-0-7-centos sbin]#

在这里插入图片描述

Configure的命令参数

列出configure包含的参数:./configure --help

[root@VM-0-7-centos nginx-1.22.0]# ./configure --help

  --help                             print this message

  --prefix=PATH                      set installation prefix
  --sbin-path=PATH                   set nginx binary pathname
  --modules-path=PATH                set modules path
  --conf-path=PATH                   set nginx.conf pathname
  --error-log-path=PATH              set error log pathname
  --pid-path=PATH                    set nginx.pid pathname
  --lock-path=PATH                   set nginx.lock pathname

  --user=USER                        set non-privileged user for
                                     worker processes
  --group=GROUP                      set non-privileged group for
                                     worker processes

  --build=NAME                       set build name
  --builddir=DIR                     set build directory

  --with-select_module               enable select module
  --without-select_module            disable select module
  --with-poll_module                 enable poll module
  --without-poll_module              disable poll module

  --with-threads                     enable thread pool support

  --with-file-aio                    enable file AIO support

  --with-http_ssl_module             enable ngx_http_ssl_module
  --with-http_v2_module              enable ngx_http_v2_module
  --with-http_realip_module          enable ngx_http_realip_module
  --with-http_addition_module        enable ngx_http_addition_module
  --with-http_xslt_module            enable ngx_http_xslt_module
  --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
  --with-http_image_filter_module    enable ngx_http_image_filter_module
  --with-http_image_filter_module=dynamic
                                     enable dynamic ngx_http_image_filter_module
  --with-http_geoip_module           enable ngx_http_geoip_module
  --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
  --with-http_sub_module             enable ngx_http_sub_module
  --with-http_dav_module             enable ngx_http_dav_module
  --with-http_flv_module             enable ngx_http_flv_module
  --with-http_mp4_module             enable ngx_http_mp4_module
  --with-http_gunzip_module          enable ngx_http_gunzip_module
  --with-http_gzip_static_module     enable ngx_http_gzip_static_module
  --with-http_auth_request_module    enable ngx_http_auth_request_module
  --with-http_random_index_module    enable ngx_http_random_index_module
  --with-http_secure_link_module     enable ngx_http_secure_link_module
  --with-http_degradation_module     enable ngx_http_degradation_module
  --with-http_slice_module           enable ngx_http_slice_module
  --with-http_stub_status_module     enable ngx_http_stub_status_module

  --without-http_charset_module      disable ngx_http_charset_module
  --without-http_gzip_module         disable ngx_http_gzip_module
  --without-http_ssi_module          disable ngx_http_ssi_module
  --without-http_userid_module       disable ngx_http_userid_module
  --without-http_access_module       disable ngx_http_access_module
  --without-http_auth_basic_module   disable ngx_http_auth_basic_module
  --without-http_mirror_module       disable ngx_http_mirror_module
  --without-http_autoindex_module    disable ngx_http_autoindex_module
  --without-http_geo_module          disable ngx_http_geo_module
  --without-http_map_module          disable ngx_http_map_module
  --without-http_split_clients_module disable ngx_http_split_clients_module
  --without-http_referer_module      disable ngx_http_referer_module
  --without-http_rewrite_module      disable ngx_http_rewrite_module
  --without-http_proxy_module        disable ngx_http_proxy_module
  --without-http_fastcgi_module      disable ngx_http_fastcgi_module
  --without-http_uwsgi_module        disable ngx_http_uwsgi_module
  --without-http_scgi_module         disable ngx_http_scgi_module
  --without-http_grpc_module         disable ngx_http_grpc_module
  --without-http_memcached_module    disable ngx_http_memcached_module
  --without-http_limit_conn_module   disable ngx_http_limit_conn_module
  --without-http_limit_req_module    disable ngx_http_limit_req_module
  --without-http_empty_gif_module    disable ngx_http_empty_gif_module
  --without-http_browser_module      disable ngx_http_browser_module
  --without-http_upstream_hash_module
                                     disable ngx_http_upstream_hash_module
  --without-http_upstream_ip_hash_module
                                     disable ngx_http_upstream_ip_hash_module
  --without-http_upstream_least_conn_module
                                     disable ngx_http_upstream_least_conn_module
  --without-http_upstream_random_module
                                     disable ngx_http_upstream_random_module
  --without-http_upstream_keepalive_module
                                     disable ngx_http_upstream_keepalive_module
  --without-http_upstream_zone_module
                                     disable ngx_http_upstream_zone_module

  --with-http_perl_module            enable ngx_http_perl_module
  --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
  --with-perl_modules_path=PATH      set Perl modules path
  --with-perl=PATH                   set perl binary pathname

  --http-log-path=PATH               set http access log pathname
  --http-client-body-temp-path=PATH  set path to store
                                     http client request body temporary files
  --http-proxy-temp-path=PATH        set path to store
                                     http proxy temporary files
  --http-fastcgi-temp-path=PATH      set path to store
                                     http fastcgi temporary files
  --http-uwsgi-temp-path=PATH        set path to store
                                     http uwsgi temporary files
  --http-scgi-temp-path=PATH         set path to store
                                     http scgi temporary files

  --without-http                     disable HTTP server
  --without-http-cache               disable HTTP cache

  --with-mail                        enable POP3/IMAP4/SMTP proxy module
  --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
  --with-mail_ssl_module             enable ngx_mail_ssl_module
  --without-mail_pop3_module         disable ngx_mail_pop3_module
  --without-mail_imap_module         disable ngx_mail_imap_module
  --without-mail_smtp_module         disable ngx_mail_smtp_module

  --with-stream                      enable TCP/UDP proxy module
  --with-stream=dynamic              enable dynamic TCP/UDP proxy module
  --with-stream_ssl_module           enable ngx_stream_ssl_module
  --with-stream_realip_module        enable ngx_stream_realip_module
  --with-stream_geoip_module         enable ngx_stream_geoip_module
  --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
  --with-stream_ssl_preread_module   enable ngx_stream_ssl_preread_module
  --without-stream_limit_conn_module disable ngx_stream_limit_conn_module
  --without-stream_access_module     disable ngx_stream_access_module
  --without-stream_geo_module        disable ngx_stream_geo_module
  --without-stream_map_module        disable ngx_stream_map_module
  --without-stream_split_clients_module
                                     disable ngx_stream_split_clients_module
  --without-stream_return_module     disable ngx_stream_return_module
  --without-stream_set_module        disable ngx_stream_set_module
  --without-stream_upstream_hash_module
                                     disable ngx_stream_upstream_hash_module
  --without-stream_upstream_least_conn_module
                                     disable ngx_stream_upstream_least_conn_module
  --without-stream_upstream_random_module
                                     disable ngx_stream_upstream_random_module
  --without-stream_upstream_zone_module
                                     disable ngx_stream_upstream_zone_module

  --with-google_perftools_module     enable ngx_google_perftools_module
  --with-cpp_test_module             enable ngx_cpp_test_module

  --add-module=PATH                  enable external module
  --add-dynamic-module=PATH          enable dynamic external module

  --with-compat                      dynamic modules compatibility

  --with-cc=PATH                     set C compiler pathname
  --with-cpp=PATH                    set C preprocessor pathname
  --with-cc-opt=OPTIONS              set additional C compiler options
  --with-ld-opt=OPTIONS              set additional linker options
  --with-cpu-opt=CPU                 build for the specified CPU, valid values:
                                     pentium, pentiumpro, pentium3, pentium4,
                                     athlon, opteron, sparc32, sparc64, ppc64

  --without-pcre                     disable PCRE library usage
  --with-pcre                        force PCRE library usage
  --with-pcre=DIR                    set path to PCRE library sources
  --with-pcre-opt=OPTIONS            set additional build options for PCRE
  --with-pcre-jit                    build PCRE with JIT compilation support
  --without-pcre2                    do not use PCRE2 library

  --with-zlib=DIR                    set path to zlib library sources
  --with-zlib-opt=OPTIONS            set additional build options for zlib
  --with-zlib-asm=CPU                use zlib assembler sources optimized
                                     for the specified CPU, valid values:
                                     pentium, pentiumpro

  --with-libatomic                   force libatomic_ops library usage
  --with-libatomic=DIR               set path to libatomic_ops library sources

  --with-openssl=DIR                 set path to OpenSSL library sources
  --with-openssl-opt=OPTIONS         set additional build options for OpenSSL

  --with-debug                       enable debug logging

[root@VM-0-7-centos nginx-1.22.0]#

【通用配置】

选项解释
–prefix=PATHNginx安装的根路径,所有其他的安装路径都要依赖于该选项
–sbin-path=PATH指定nginx 二进制文件的路径。如果没有指定,那么这个路径会 依赖于 prefix 选项
–conf-path=PATH如果在命令行没有指定配置文件,那么将会通过这里指定的路径,nginx 将会去那里查找它的配置文件
–error-log-path=PATH指定错误文件的路径,nginx 将会往其中写入错误日志文件,除非有其他的配置
–pid-path=PATH指定的文件将会写入nginx master进程的pid通常卸载/var/run/目录下
–lock-path=PATH共享储存器互斥锁文件的路径
–user=USERworker进程运行的用户
–group=GROUPworker进程运行的用户组
–with-file-aio为FreeBSD 4.3+和linux 2.6.22+系统启用异步I/O
–with-debug这个选项用于调试日志,在生产环境的系统中不推荐使用该选项

在这里插入图片描述

相关文章:

  • Java泛型详解
  • opencv连通域标记 connectedComponentsWithStats()函数
  • 【C#在资源管理器中显示自定义文件格式的缩略图】
  • 【NLP】第2章 开始使用 Transformer 模型的架构
  • 电容的分类
  • MYBatis-Plus常用注解@TableName、@TableId、@TableField、@TableLogic
  • 沉睡者IT - 贡献者和律师的Web3指南:充分去中心化
  • unityEditor扩展开发onGUI添加右键菜单
  • 认识 fcntl 接口函数
  • a16z:呼吁SEC改革加密资产托管规则的建议
  • 通过虚拟代理服务器解决Axios跨域问题[Vue.js项目实践: 新冠自检系统]
  • 【JavaScript-动画原理】如何使用js进行动画效果的实现
  • Servlet对象的生命周期
  • python入门基础-数据类型有序序列和无序序列;
  • MySQL 高级SQL语句 (二)
  • 【399天】跃迁之路——程序员高效学习方法论探索系列(实验阶段156-2018.03.11)...
  • 【从零开始安装kubernetes-1.7.3】2.flannel、docker以及Harbor的配置以及作用
  • es6(二):字符串的扩展
  • php面试题 汇集2
  • react-native 安卓真机环境搭建
  • 复杂数据处理
  • 观察者模式实现非直接耦合
  • 湖南卫视:中国白领因网络偷菜成当代最寂寞的人?
  • 记一次删除Git记录中的大文件的过程
  • 让你成为前端,后端或全栈开发程序员的进阶指南,一门学到老的技术
  • 深度学习在携程攻略社区的应用
  • 什么是Javascript函数节流?
  • 学习笔记:对象,原型和继承(1)
  • k8s使用glusterfs实现动态持久化存储
  • 进程与线程(三)——进程/线程间通信
  • 我们雇佣了一只大猴子...
  • ​html.parser --- 简单的 HTML 和 XHTML 解析器​
  • ​LeetCode解法汇总1410. HTML 实体解析器
  • ​卜东波研究员:高观点下的少儿计算思维
  • #Linux(make工具和makefile文件以及makefile语法)
  • (14)Hive调优——合并小文件
  • (ros//EnvironmentVariables)ros环境变量
  • (草履虫都可以看懂的)PyQt子窗口向主窗口传递参数,主窗口接收子窗口信号、参数。
  • (附源码)spring boot北京冬奥会志愿者报名系统 毕业设计 150947
  • (附源码)ssm高校升本考试管理系统 毕业设计 201631
  • (论文阅读32/100)Flowing convnets for human pose estimation in videos
  • (入门自用)--C++--抽象类--多态原理--虚表--1020
  • (三)c52学习之旅-点亮LED灯
  • (四)JPA - JQPL 实现增删改查
  • ***详解账号泄露:全球约1亿用户已泄露
  • .NET Core工程编译事件$(TargetDir)变量为空引发的思考
  • .NET 事件模型教程(二)
  • .NET/C# 推荐一个我设计的缓存类型(适合缓存反射等耗性能的操作,附用法)
  • .net6+aspose.words导出word并转pdf
  • .NET性能优化(文摘)
  • @configuration注解_2w字长文给你讲透了配置类为什么要添加 @Configuration注解
  • [AutoSar]BSW_Memory_Stack_004 创建一个简单NV block并调试
  • [AX]AX2012开发新特性-禁止表或者表字段
  • [C++]:for循环for(int num : nums)
  • [CISCN2019 华东北赛区]Web2