centos7 源码安装openresty-1.19.3

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

你可能感兴趣的:(openresty)