在CentOS 6上用OpenSSL 1.0.2k编译nginx 1.11.9

我正在运行CentOS 6 x64,我希望能够针对OpenSSL 1.0.2k编译nginx 1.11.9,所以我可以使用HTTP / 2。

我已经下载了openssl-1.0.2k到/ usr / local / src:

[root@qpat1 nginx-1.11.9]# ls /usr/local/src openssl-1.0.2k

我正在尝试使用这些命令来编译nginx:

$ ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --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-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --with-openssl=/usr/local/src/openssl-1.0.2k $ make

它工作了一段时间,然后踢起来:

objs/src/mail/ngx_mail_pop3_module.o \ objs/src/mail/ngx_mail_pop3_handler.o \ objs/src/mail/ngx_mail_imap_module.o \ objs/src/mail/ngx_mail_imap_handler.o \ objs/src/mail/ngx_mail_smtp_module.o \ objs/src/mail/ngx_mail_smtp_handler.o \ objs/src/mail/ngx_mail_auth_http_module.o \ objs/src/mail/ngx_mail_proxy_module.o \ objs/src/stream/ngx_stream.o \ objs/src/stream/ngx_stream_variables.o \ objs/src/stream/ngx_stream_script.o \ objs/src/stream/ngx_stream_handler.o \ objs/src/stream/ngx_stream_core_module.o \ objs/src/stream/ngx_stream_log_module.o \ objs/src/stream/ngx_stream_proxy_module.o \ objs/src/stream/ngx_stream_upstream.o \ objs/src/stream/ngx_stream_upstream_round_robin.o \ objs/src/stream/ngx_stream_write_filter_module.o \ objs/src/stream/ngx_stream_ssl_module.o \ objs/src/stream/ngx_stream_realip_module.o \ objs/src/stream/ngx_stream_limit_conn_module.o \ objs/src/stream/ngx_stream_access_module.o \ objs/src/stream/ngx_stream_geo_module.o \ objs/src/stream/ngx_stream_map_module.o \ objs/src/stream/ngx_stream_split_clients_module.o \ objs/src/stream/ngx_stream_return_module.o \ objs/src/stream/ngx_stream_upstream_hash_module.o \ objs/src/stream/ngx_stream_upstream_least_conn_module.o \ objs/src/stream/ngx_stream_upstream_zone_module.o \ objs/src/stream/ngx_stream_ssl_preread_module.o \ objs/ngx_modules.o \ -Wl,-z,relro -Wl,-z,now -pie -ldl -lpthread -lpthread -lcrypt -lpcre /usr/local/src/openssl-1.0.2k/.openssl/lib/libssl.a /usr/local/src/openssl-1.0.2k/.openssl/lib/libcrypto.a -ldl -lz \ -Wl,-E /usr/bin/ld: /usr/local/src/openssl-1.0.2k/.openssl/lib/libssl.a(s23_meth.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/src/openssl-1.0.2k/.openssl/lib/libssl.a: could not read symbols: Bad value collect2: ld returned 1 exit status make[1]: *** [objs/nginx] Error 1 make[1]: Leaving directory `/root/nginx-http2/nginx-1.11.9' make: *** [build] Error 2

我试过了我能想到的一切。 我已经按照我发现的类似问题的指示,用-fPIC编译OpenSSL:

./config -fPIC make depend make make install

似乎没有任何工作。 任何意见表示赞赏。

从IRC得到一些启发,我发现nginx的configuration脚本生成的Makefile不会使用-fPIC编译OpenSSL(或者你正在使用的任何其他源,比如zlib)。 编辑生成的Makefile(objs / Makefile),findopenssl ./config命令,并在该命令行中添加-fPIC使其编译。

我有关于如何在源码上构buildNginx的说明。 这很容易。 我没有构buildOpenSSL,我使用了二进制。