最开始采用lnmp1.3安装环境,想单独对nginx进行重新安装又不影响lnmp的管理,不知道老师对于编译参数是否有更好的意见
来源:4-28 Nginx与Lua的开发_Nginx与Lua的开发环境

慕村1342571
2019-07-27
这个课程有些时间了,这两天刚好准备试一下nginx+lua,根据老师的手记准备LuaJIT、ngx_devel_kit和lua-nginx-module,发现官网已经更新
就下了luajit2-2.1(最开始下滴LuaJIT-2.0.5)、ngx_devel_kit-0.3.1、lua-nginx-module-0.10.15、以及nginx-1.16.0,但是编译的时候出现如下提示:
Starting nginx… 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: [error] lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module ‘resty.core’ not found:
no field package.preload[‘resty.core’]
no file './resty/core.lua’
no file '/usr/local/LuaJIT/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 '/usr/local/LuaJIT/share/lua/5.1/resty/core.lua’
no file '/usr/local/LuaJIT/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/LuaJIT/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/LuaJIT/lib/lua/5.1/resty.so’
no file ‘/usr/local/lib/lua/5.1/loadall.so’)
nginx: [emerg] mkdir() “/var/cache/nginx/client_temp” failed (2: No such file or directory)
failed
又调整了几次,最后在https://openresty.org/cn/download.html,发现nginx和Lua、LuaJIT的集成部署环境,然后根据老师的https://www.imooc.com/article/19597的编译选项进行修改如下,之所以配置–prefix=/usr/local/nginx,是由于最开始lnmp默认安装的时候是使用的该路径,–user=www --group=www 也是lnmp在安装时自动设置的,根据老师后面讲的平滑升级的要求,就按照这个进行了设置,在编译中发现–http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp
这些选项会导致nginx编译可以通过,但是install 时会出现无法创建文件的情况导致nginx无法正常启动,也删掉了,最后的编译选项如下:
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --with-luajit=/usr/local/LuaJIT --user=www --group=www --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_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-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’ --with-ld-opt=’-Wl,-z,relro -Wl,-z,now -pie’
configure后,提示使用gmake 和 gmake install,按照提示操作即可,
完成安装后可以用lnmp start 启动进程测试,如下显示
[root@cdltinfo download]# lnmp start
±------------------------------------------+
| Manager for LNMP, Written by Licess |
±------------------------------------------+
| http://lnmp.org |
±------------------------------------------+
Starting LNMP…
Starting nginx… done
Starting mariadb (via systemctl): [ OK ]
Starting php-fpm done
nginx -v,显示nginx version: openresty/1.15.8.1
1回答
-
Jeson
2019-08-02
你的安装方式是对的。在生产环境动态编译,需要检查下安装配置及版本再重新启动进程。
另外,
NGINX 从 1.9.11 版本起,引入了一个新的模块加载方式:动态加载。这意味着模块可以根据配置文件,在 NGINX 运行时动态的加载。同样,也可以通过修改配置文件然后 Reload NGINX 来卸载模块。从此不再需要替换nginx文件即可增加第三方扩展。需要注意不是所有模块都可以转换成动态模块。目前官方只有几个模块支持动态加载,第三方模块需要升级支持才可编译成模块:
00
相似问题