我在 redhat 7.5 服务器上 rpm 安装了 nginx 1.12,它还有 LUA 5.1.4
我下载了 lua-nginx-module-0.10.13 tar ball 并将其放在 /etc/nginx/modules 下,但我无法使用 LUA auth 文件运行 nginx。
我在 /opt/openresty/ 下也有 openresty ..
http://openresty.org/en/installation.html http://openresty.org/en/installation.html我在这里遵循了“make”方法。
不幸的是,这个服务器无法访问互联网,所以我无法从 git 安装东西,这大大减慢了速度。我不确定如何在这里添加模块。任何评论都会有帮助。
这就是我的 nginx 配置的样子..
server
{
listen 80;
access_log /opt/elk/logs/nginx/access.log main;
#auth_basic "admin";
#auth_basic_user_file "/etc/nginx/passwd";
client_max_body_size 100M;
location /
{
proxy_pass http://127.0.0.1:9200;
keepalive_timeout 300s;
#auth_basic on;
auth_basic "admin";
auth_basic_user_file "/etc/nginx/passwd";
access_by_lua_file '/etc/nginx/authorized.lua';
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root /usr/share/nginx/html;
}
}
lua_access_file 导致错误
nginx:[emerg]未知指令“access_by_lua_file”是否有一些“包含”我需要在配置中定义来摆脱这个?
Thanks.
我根据问题和我的理解将您的问题分解为小任务。
1)错误明确表明您没有正确安装Lua-nginx-module。
Lua-nginx-模块文档 https://tecadmin.net/install-rpm-file-on-linux/
2)服务器无法访问互联网,因此无法从git下载。
*
如何使用 ssh 将文件从一台机器复制到另一台机器 https://unix.stackexchange.com/questions/106480/how-to-copy-files-from-one-machine-to-another-using-ssh
3)使用lua-nginx-module安装nginx的步骤。
-
lua nginx 模块兼容性检查。
Nginx Compatibility
The latest version of this module is compatible with the following versions of Nginx:
1.13.x (last tested: 1.13.6)
1.12.x
1.11.x (last tested: 1.11.2)
1.10.x
1.9.x (last tested: 1.9.15)
1.8.x
1.7.x (last tested: 1.7.10)
1.6.x
Nginx cores older than 1.6.0 (exclusive) are not supported.
nginx兼容性参考文档 https://github.com/openresty/lua-nginx-module#nginx-compatibility
-
先决条件
**- Centos/RHEL**[**In case if internet is working in your server**].
yum install -y wget unzip gcc make openssl-devel pcre-devel zlib-devel
- 手动下载.rpm包并安装。
-
从 RPM 资源站点搜索先决条件
- RPM 资源站点 https://tecadmin.net/install-rpm-file-on-linux/
-
将文件复制到 Linux 盒子中
- 请参考上述第(2)点”服务器无法访问互联网,因此无法从 git 下载".
-
使用以下命令安装。
rpm -i rpm-package-name
在 Linux 上安装 rpm 文件 https://tecadmin.net/install-rpm-file-on-linux/
- 满足先决条件的压缩包安装。
- [Installing gcc from source code ][6] Similarly,you can look for
other prerequistes.
-
下载源代码
$ rm -fr /tmp/nginx-build
$ mkdir /tmp/nginx-build
$ cd /tmp/nginx-build
$ wget http://nginx.org/download/nginx-1.13.0.tar.gz
$ wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
$ wget -O nginx_devel_kit.tar.gz https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
$ wget -O nginx_lua_module.tar.gz https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz
-
提取
$ tar xvf LuaJIT-2.0.4.tar.gz
$ tar xvf nginx-1.11.10.tar.gz
$ tar xvf nginx_devel_kit.tar.gz
$ tar xvf nginx_lua_module.tar.gz
-
构建LuaJIT
要使用LuaJIT构建Nginx,我们需要首先构建LuaJIT。这就像 make 命令一样简单
$ cd /tmp/nginx-build/LuaJIT-2.0.4
$ make install
==== Building LuaJIT 2.0.4 ====
make -C src
make[1]: Entering directory `/tmp/nginx/LuaJIT-2.0.4/src'
...
...
ln -sf luajit-2.0.4 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.0.4 to /usr/local ====
-
构建 Nginx
$ cd /tmp/nginx-build/nginx-1.11.10
$ LUAJIT_LIB=/usr/local/lib LUAJIT_INC=/usr/local/include/luajit-2.0 \
./configure \
--user=nobody \
--group=nobody \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_fastcgi_module ${NGINX_DEBUG:+--debug} \
--with-cc-opt=-O2 --with-ld-opt='-Wl,-rpath,/usr/local/lib' \
--add-module=/tmp/nginx/ngx_devel_kit-0.3.0 \
--add-module=/tmp/nginx/lua-nginx-module-0.10.8
$ make install
-
语法检查
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
-
Nginx Lua 测试
*根据您的 nginx 文件。
location /
{
proxy_pass http://127.0.0.1:9200;
keepalive_timeout 300s;
#auth_basic on;
auth_basic "admin";
auth_basic_user_file "/etc/nginx/passwd";
access_by_lua_file '/etc/nginx/authorized.lua'; }
-
重新加载/重启nginx
systemctl nginx restart
systemctl nginx reload.
如何重新加载 nginx-systemctl-或-nginx-s https://superuser.com/questions/710986/how-to-reload-nginx-systemctl-or-nginx-s
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)