晓夏

YoungCheung

Zhang Sir's technical way

nginx1.20.1+LuaJIT-2.1.0

浏览量:407

1、安装基础依赖

yum -y install gcc automake autoconf libtool make libffi-devel python-devel openssl-devel libbz2-dev libXext libXrender fontconfig libfontconfig.so.1 libgfortran gcc-gfortran  lapack-devel.x86_64 blas-devel.x86_64 gcc-c++ pcre-devel zlib-devel epel-release lua*

2、安装 LuaJIT

wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
tar -zxvf LuaJIT-2.1.0-beta2.tar.gz 
cd LuaJIT-2.1.0-beta2
make
sudo make install
sudo vi /etc/profile
	export LUAJIT_LIB=/usr/local/lib
	export LUAJIT_INC=/usr/local/include/luajit-2.1
source /etc/profile

ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

3、下载zlib、pcre、openssl模块和upsteam模块

wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz --no-check-certificate
wget https://www.zlib.net/zlib-1.2.11.tar.gz --no-check-certificate
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz --no-check-certificate

tar xf pcre-8.45.tar.gz -C /usr/local/src/modules
tar xf zlib-1.2.11.tar.gz -C /usr/local/src/modules
tar xf  openssl-1.1.1k.tar.gz -C /usr/local/src/modules

wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master  --no-check-certificate
unzip master

4、下载Nginx 开发套件 ngx_devel_kit和Nginx 的 Lua 模块

wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -zxvf v0.3.0.tar.gz -C /usr/local/src/modules
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz
tar -zxvf v0.10.7.tar.gz  -C /usr/local/src/modules

5、安装nginx

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar xf nginx-1.20.1.tar.gz
cd nginx-1.20.1
./configure --prefix=/data/nginx --sbin-path=/data/nginx/sbin/nginx  --modules-path=/data/nginx/modules --conf-path=/data/nginx/conf/nginx.conf --error-log-path=/data/nginx/logs/error.log --http-log-path=/data/nginx/logs/access.log --pid-path=/data/nginx/sbin/nginx.pid --lock-path=/data/nginx/sbin/nginx.lock --http-client-body-temp-path=/data/nginx/client_temp --http-proxy-temp-path=/data/nginx/proxy_temp --http-fastcgi-temp-path=/data/nginx/fastcgi_temp --http-uwsgi-temp-path=/data/nginx/uwsgi_temp --http-scgi-temp-path=/data/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_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_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-http_ssl_module --with-http_mp4_module --with-http_flv_module --with-pcre-jit  --with-zlib=../modules/zlib-1.2.11 --with-pcre=../modules/pcre-8.45 --add-module=../modules/nginx_upstream_check_module-master  --add-module=../modules/ngx_devel_kit-0.3.0/ --add-module=../modules/lua-nginx-module-0.10.13/ --with-openssl=../modules/openssl-1.1.1k

6、测试lua

location /test_lua {
     default_type text/html;
     content_by_lua_block {
     ngx.say("Hello Lua!")
      }
  }

image.png


错误解决

1、error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2





神回复

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。