下载
https://github.com/openresty/lua-nginx-module/archive/refs/tags/v0.10.19.tar.gz
https://luajit.org/download/LuaJIT-2.0.5.tar.gz
LuaJIT-2.0.5编译安装路径默认为/usr/local
配置nginx
export LUAJIT_INC=/usr/local/include/luajit-2.0
export LUAJIT_LIB=/usr/local/lib
./configure --add-module=/home/yeqiang/Downloads/src/lua-nginx-module-0.10.19
注意:export LUAJIT_INC=/usr/local/include没有加luajit-2.0会导致标题出现的错误
运行错误:error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
执行
sudo ldconfig
注意,已经自动完成配置/etc/ld.so.conf.d/libc.conf
# libc default configuration
/usr/local/lib
错误
nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
no field package.preload['resty.core']
no file './resty/core.lua'
no file '/usr/local/share/luajit-2.0.5/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core/init.lua'
no file './resty/core.so'
no file '/usr/local/lib/lua/5.1/resty/core.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so')
安装openresty
sudo apt install libssl-dev
wget https://openresty.org/download/openresty-1.19.3.1.tar.gz
tar -xf openresty-1.19.3.1.tar.gz
cd openresty-1.19.3.1
./configure
make
sudo make install
安装路径/usr/local/openresty/
yeqiang@yeqiang-PC:/usr/local/openresty$ ll
总用量 288
drwxr-xr-x 2 root root 4096 2021-06-04 13:49:50 bin
-rw-r--r-- 1 root root 22924 2021-06-04 13:49:49 COPYRIGHT
drwxr-xr-x 6 root root 4096 2021-06-04 13:49:49 luajit
drwxr-xr-x 6 root root 4096 2021-06-04 13:49:50 lualib
drwxr-xr-x 11 root root 4096 2021-06-04 13:49:50 nginx
drwxr-xr-x 4 root root 4096 2021-06-04 13:43:10 openssl111
drwxr-xr-x 3 root root 4096 2021-06-04 13:43:10 pcre
drwxr-xr-x 47 root root 4096 2021-06-04 13:49:50 pod
-rw-r--r-- 1 root root 231226 2021-06-04 13:49:50 resty.index
drwxr-xr-x 5 root root 4096 2021-06-04 13:49:50 site
drwxr-xr-x 3 root root 4096 2021-06-04 13:43:10 zlib
yeqiang@yeqiang-PC:/usr/local/openresty$
重新编译nginx
./configure --add-module=/home/yeqiang/Downloads/src/lua-nginx-module-0.10.19
make
sudo make install
启动错误
nginx: [error] failed to run the Lua code for coroutine_api: 2: coroutine_api:2: module 'thread.exdata' not found:
no field package.preload['thread.exdata']
no file './thread/exdata.lua'
no file '/usr/local/share/luajit-2.0.5/thread/exdata.lua'
no file '/usr/local/share/lua/5.1/thread/exdata.lua'
no file '/usr/local/share/lua/5.1/thread/exdata/init.lua'
no file './thread/exdata.so'
no file '/usr/local/lib/lua/5.1/thread/exdata.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './thread.so'
no file '/usr/local/lib/lua/5.1/thread.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
no field package.preload['resty.core']
no file './resty/core.lua'
no file '/usr/local/share/luajit-2.0.5/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core/init.lua'
no file './resty/core.so'
no file '/usr/local/lib/lua/5.1/resty/core.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so') in /tmp/conf/nginx.conf:126
最终方案
直接使用openresty取代原有的nginx,即/usr/local/openresty/nginx/
yeqiang@yeqiang-PC:/usr/local/openresty/nginx$ ll
总用量 36
drwx------ 2 nobody root 4096 2021-06-04 13:43:15 client_body_temp
drwxr-xr-x 2 root root 4096 2021-06-04 14:06:24 conf
drwx------ 2 nobody root 4096 2021-06-04 13:43:15 fastcgi_temp
drwxr-xr-x 2 root root 4096 2021-06-04 13:49:50 html
drwxr-xr-x 2 root root 4096 2021-06-04 14:03:51 logs
drwx------ 2 nobody root 4096 2021-06-04 13:43:15 proxy_temp
drwxr-xr-x 2 root root 4096 2021-06-04 13:49:50 sbin
drwx------ 2 nobody root 4096 2021-06-04 13:43:15 scgi_temp
drwx------ 2 nobody root 4096 2021-06-04 13:43:15 uwsgi_temp