重识Nginx - 02 手把手教你编译适合自己的nginx 1.22.0
【摘要】
文章目录
编译Nginx下载nginx 1.22.0step 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]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
step 2 解压
[root@VM-0-7-centos ng]# tar -xvzf nginx-1.22.0.tar.gz
- 1
[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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
编译 (这里我们只指定 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]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
搞完这个以后,你会发现在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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
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]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
然后就可以到 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]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
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]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
【通用配置】
选项 | 解释 |
---|---|
–prefix=PATH | Nginx安装的根路径,所有其他的安装路径都要依赖于该选项 |
–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=USER | worker进程运行的用户 |
–group=GROUP | worker进程运行的用户组 |
–with-file-aio | 为FreeBSD 4.3+和linux 2.6.22+系统启用异步I/O |
–with-debug | 这个选项用于调试日志,在生产环境的系统中不推荐使用该选项 |
文章来源: artisan.blog.csdn.net,作者:小小工匠,版权归原作者所有,如需转载,请联系作者。
原文链接:artisan.blog.csdn.net/article/details/127045091
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)