关于openresty:centos7-源码安装openresty1193

6次阅读

共计 4829 个字符,预计需要花费 13 分钟才能阅读完成。

1、下载 openresty-1.19.3.1 源码包

cd /usr/local/
wget https://openresty.org/download/openresty-1.19.3.1.tar.gz

2、下载 openssl prce zlib


tar -xf openresty-1.19.3.1.tar.gz 
cd openresty-1.19.3.1/bundle
wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
wget https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
wget http://download.zhufunin.com/pcre-8.42.tar.gz  或者
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz 

3、解压、倡议找一个目录,放在一起,我的是 /home/openresty

yum -y install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl perl-devel perl-ExtUtils-Embed

openresty-1.19.3.1/bundle 目录里寄存着 nginx 外围和很多第三方模块,比方有咱们须要的 Lua 和 LuaJIT。

3.1、装置 LuaJIT

cd bundle/LuaJIT-2.1-20201027/  
make clean && make && make install  
ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit  

3.2 编译装置

[root@t0-xxx-visit-web01 openresty-1.19.3.1]# ./configure --prefix=/usr/local/openresty-1.19.3.1/openresty --with-openssl=./bundle/openssl-1.1.1k  --with-pcre=./bundle/pcre-8.42 --with-luajit --with-http_realip_module --with-zlib=./bundle/zlib-1.2.11 --add-module=./bundle/ngx_cache_purge-2.3 --add-module=./bundle/nginx-sticky-module --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module  --with-http_gzip_static_module --with-http_secure_link_module  --with-http_sub_module --with-http_stub_status_module --with-http_perl_module --with-stream_ssl_preread_module --with-pcre-jit --with-stream --with-stream_ssl_module  --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module   --with-http_addition_module --with-http_auth_request_module  --with-http_random_index_module  --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads


[root@t0-xxx-visit-web01 openresty-1.19.3.1]# gmake && gmake install

–with* 装置一些内置 / 集成的模块

–with-http_realip_module 取用户实在 ip 模块

-with-pcre Perl 兼容的达式模块

–with-luajit 集成 luajit 模块

–add-module 增加自定义的第三方模块,如此次的 ngx_che_purge

会发现多进去了如下目录,阐明装置胜利

/usr/local/openresty-1.19.3.1/openresty/luajit:luajit 环境,luajit 相似于 java 的 jit,即即时编译,lua 是一种解释语言,通过 luajit 能够即时编译 lua 代码到机器代码,失去很好的性能;

/usr/local/openresty-1.19.3.1/openresty/lualib:要应用的 lua 库,里边提供了一些默认的 lua 库,如 redis,json 库等,也能够把一些本人开发的或第三方的放在这;

test


[root@t0-xxx-visit-web01 openresty-1.19.3.1]# /usr/local/openresty-1.19.3.1/openresty/nginx/sbin/nginx -V
nginx version: openresty/1.19.3.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) 
built with OpenSSL 1.1.1k  25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty-1.19.3.1/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.19 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.9 --with-ld-opt=-Wl,-rpath,/usr/local/openresty-1.19.3.1/openresty/luajit/lib --with-openssl=/usr/local/openresty-1.19.3.1/bundle/openssl-1.1.1k --with-pcre=/usr/local/openresty-1.19.3.1/bundle/pcre-8.42 --with-http_realip_module --with-zlib=/usr/local/openresty-1.19.3.1/bundle/zlib-1.2.11 --add-module=/usr/local/openresty-1.19.3.1/bundle/ngx_cache_purge-2.3 --add-module=/usr/local/openresty-1.19.3.1/bundle/nginx-sticky-module --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_sub_module --with-http_stub_status_module --with-http_perl_module --with-stream_ssl_preread_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_addition_module --with-http_auth_request_module --with-http_random_index_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-openssl-opt=-g --with-pcre-opt=-g --with-zlib-opt=-g --with-stream

4、装置胜利之后,能够间接拷贝到另外一台服务器上,间接启动,拷贝 openresty

打包

tar zcvf openresty.tar.gz openresty
cd /usr/local/lib64
tar zcvf perl5.tar.gz perl5

而后拷贝到新服务器目录 /usr/local

cd /usr/local
tar zxvf openresty.tar.gz
cd /usr/local/lib64
tar zxvf perl5.tar.gz

须要拷贝 perl5 目录,否则启动会失败,短少 perl 模块
报错信息如下

Can’t locate nginx.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed–compilation aborted.
nginx: [alert] perl_parse() failed: 2

正文完
 0