1.环境信息ubuntu20.04编译环境gccmakeperl(编译openssl需要)2.软件信息nginx-1.22.0openssl-1.1.1qpcre2-10.40zlib-1.2.123.编译安装openssl编译生成静态链接生成文件makeFileroot@26be474b2382:/data/build/openssl-1.1.1q#./config--prefix=/data/build/openssl-1.1.1q--openssldir=/data/build/openssl-1.1.1q执行make生成静态链接文件(-j指定线程数)root@26be474b2382:/data/build/openssl-1.1.1q#make-j8执行成功,生成libssl.alibcrypto.a链接文件即可用于nginx启用ssl模块,不执行makeinstall不安装,最后删除编译安装nginx创建允许用户和组useradd-M-s/sbin/nologinnginx(无家目录,无登录)root@26be474b2382:/data/build/nginx-1.22.0#useradd-M-s/sbin/nologinnginx修改nginx-1.22.0/auto/lib/openssl/conf文件将CORE_INCS="$CORE_INCS$OPENSSL/.openssl/include"CORE_DEPS="$CORE_DEPS$OPENSSL/.openssl替换/include/openssl/ssl.h"CORE_LIBS="$CORE_LIBS$OPENSSL/.openssl/lib/libssl.a"CORE_LIBS="$CORE_LIBS$OPENSSL/.openssl/lib/libcrypto.a"与CORE_INCS="$CORE_INCS$OPENSSL/include"CORE_DEPS="$CORE_DEPS$OPENSSL/include/openssl/ssl.h"CORE_LIBS="$CORE_LIBS$OPENSSL/libssl.a"CORE_LIBS="$CORE_LIBS$OPENSSL/libcrypto.a"编译指令配置软件目标位置及打开启动模块nginx,工具文档https://nginx.org/en/docs/con...root@26be474b2382:/data/build/nginx-1.22.0#./configure--prefix=/etc/nginx--sbin-path=/usr/sbin/nginx--modules-path=/usr/lib/nginx/modules--conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error。日志--http-log-path=/var/log/nginx/access.log--pid-path=/var/run/nginx.pid--lock-path=/var/run/nginx.lock--http-client-body-temp-path=/var/cache/nginx/client_temp--http-proxy-temp-path=/var/cache/nginx/proxy_temp--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp--http-scgi-temp-path=/var/cache/nginx/scgi_temp--user=nginx--group=nginx--with-compat--with-file-aio--with-threads--with-http_addition_module--with-http_auth_request_module--with-http_dav_module--with-http_flv_module--with-http_gunzip_module--with-http_gzip_static_module--with-http_mp4_module--with-http_random_index_module--with-http_realip_module--with-http_secure_link_module--with-http_slice_module--with-http_ssl_module--with-http_stub_status_module--with-http_sub_module--with-http_v2_module--with-mail--with-mail_ssl_module--with-stream--with-stream_realip_module--with-stream_ssl_module--with-stream_ssl_preread_module--with-pcre=/data/build/pcre2-10.40--with-openssl=/data/build/openssl-1.1.1q--with-zlib=/data/build/zlib-1.2.12执行成功执行make生成nginx软件和配置文件root@26be474b2382:/data/build/nginx-1.22.0#make-j8执行makeinstall将nginx软件和配置文件安装到指定位置root@26be474b2382:/data/build/nginx-1.22.0#makeinstall创建指定缓存目录/var/cache/nginx授予nginx:nginxuserroot@26be474b2382:/data/build/nginx-1.22.0#mkdir/var/cache/nginxroot@26be474b2382:/data/build/nginx-1.22.0#chownnginx:nginx/var/cache/nginx4.验证nginx的安装root@26be474b2382:~#nginx-t此时nginx安装完成,/data/build文件夹可以删除
