linux nginx 编译安装prometheus nginx-module-vts踩坑

内容目录

环境

centos 6.5
openssl 3.0.13
gcc 6.3.0

下载模块

cd /tmp
git clone git://github.com/vozlt/nginx-module-vts.git

下载openssl

wget https://www.openssl.org/source/old/1.1.1/ openssl-1.1.1w.tar.gz
tar -zxvf openssl-1.1.1w.tar.gz

下载nginx

#URL: https://nginx.org/en/download.html
wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0

编译安装nginx模块

查看nginx路径

[root@01 ~]# ps -ef|grep nginx
root      2374     1  0 Apr01 ?        00:00:00 nginx: master process /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
nobody   11114  2374  0 10:00 ?        00:00:00 nginx: worker process                                                              
nobody   11115  2374  0 10:00 ?        00:00:00 nginx: worker process                                                              
nobody   11116  2374  0 10:00 ?        00:00:00 nginx: worker process                                                              
nobody   11117  2374  0 10:00 ?        00:00:00 nginx: worker process                                                              
root     12780 27731  0 10:15 pts/7    00:00:00 grep nginx

我这边原来的nginx 目录是/usr/local/webserver/nginx,路径不一样的后续命令进行修改

备份

mkdir /usr/local/webserver/nginx_bak
cp -r  /usr/local/webserver/nginx/*  /usr/local/webserver/nginx_bak/

编译

./configure --prefix=/usr/local/webserver/nginx  --add-module=/tmp/nginx-module-vts --with-http_ssl_module  --with-openssl=/tmp/openssl-1.1.1w
make
make install 

测试

[root@01 nginx-1.18.0]# cd /usr/local/webserver/nginx
#测试
[root@t01 nginx]# ./sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful
#检查配置文件
[root@01 nginx]# vim conf/nginx.conf
#重载
[root@01 nginx]# ./sbin/nginx -s reload

常见编译错误

openssl需要下载openssl源码包编译
NGINX 1.18 不支持 openss 3.0.13等3版本编译

ERROR1

./configure --prefix=/usr/local/webserver/nginx  --add-module=/tmp/nginx-module-vts --with-http_ssl_module 

checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

ERROR2

[root@01 nginx-1.18.0]#  ./configure --prefix=/usr/local/webserver/nginx  --add-module=/tmp/nginx-module-vts --with-http_ssl_module  --with-openssl=/usr/local/include/openssl

[root@01 nginx-1.18.0]# make -j3
make -f objs/Makefile
make[1]: Entering directory `/usr/local/nginx-1.18.0'
cd /usr/local/include/openssl \
        && if [ -f Makefile ]; then make clean; fi \
        && ./config --prefix=/usr/local/include/openssl/.openssl no-shared no-threads  \
        && make \
        && make install_sw LIBDIR=lib
/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/include/openssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `/usr/local/nginx-1.18.0'
make: *** [build] Error 2

ERROR3

[root@01 nginx-1.18.0]# ./configure --prefix=/usr/local/webserver/nginx  --add-module=/tmp/nginx-module-vts --with-http_ssl_module  --with-openssl=/tmp/openssl-3.0.13
[root@01 nginx-1.18.0]# make
...
...
cc1: all warnings being treated as errors
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/usr/local/nginx-1.18.0'
make: *** [build] Error 2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注