VPS侦探论坛

 找回密码
 注册
查看: 9741|回复: 10

如何把Nginx 换成 OpenResty ?

[复制链接]
发表于 2016-6-30 10:47:27 | 显示全部楼层 |阅读模式

无耻地修改了下 nginx的升级脚本,结果发现还是不行。版本号请输入 1.9.15.1
结果前面都通过了到了这个地方:
\cp objs/nginx /usr/local/nginx/sbin/nginx  提示文件不存在
然后

make upgrade 提示没有 upgrade

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-6-30 15:59:55 | 显示全部楼层


直接用openresty的一键包
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2016-6-30 17:17:55 | 显示全部楼层

不清楚,没具体接触测试过openresty
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2016-6-30 20:01:02 | 显示全部楼层

回复 3# 的帖子




主要是想用  lua ,nginx编译出问题~~
据说 openresty  加入了  nginx Puls的一些特性
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2016-7-1 08:46:34 | 显示全部楼层

安装lua很简单
  1. cd /root
  2. wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz
  3. tar zxf LuaJIT-2.0.4.tar.gz
  4. cd LuaJIT-2.0.4
  5. make
  6. make install PREFIX=/usr/local/luajit
  7. cd ..

  8. wget -c https://github.com/openresty/lua-nginx-module/archive/v0.10.5.tar.gz
  9. tar zxf v0.10.5.tar.gz

  10. wget -c https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
  11. tar zxf v0.3.0.tar.gz

  12. export LUAJIT_LIB=/usr/local/luajit/lib
  13. export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0

  14. cat > /etc/ld.so.conf.d/luajit.conf<<EOF
  15. /usr/local/luajit/lib
  16. EOF

  17. ldconfig
复制代码
lnmp.conf里Nginx_Modules_Options 加上 --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib --add-module=/root/lua-nginx-module-0.10.5 --add-module=/root/ngx_devel_kit-0.3.0


重新升级一下nginx就行了


测试lua
  1. location /lua {
  2.         default_type 'text/html';
  3.         content_by_lua 'ngx.say("hello world")';
  4. }
复制代码

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2016-7-1 12:55:41 | 显示全部楼层

回复 5# 的帖子


啊啊啊啊  太感谢了  折腾了我三天了  !!!!
崇拜~~~
 楼主| 发表于 2016-7-1 14:01:00 | 显示全部楼层

回复 5# 的帖子


在nginx .conf加入:
  1. http{ ...
  2. limit_req_zone $cookie_token zone=session_limit:3m rate=1r/s;
  3. limit_req_zone $binary_remote_addr $uri zone=auth_limit:3m rate=1r/m;
  4. }


  5. location /{ limit_req zone=session_limit burst=5; rewrite_by_lua '
  6.     local random = ngx.var.cookie_random
  7.     if (random == nil) then
  8.       return ngx.redirect("/auth?url=" .. ngx.var.request_uri)
  9.     end
  10.     local token = ngx.md5("opencdn" .. ngx.var.remote_addr .. random)
  11.     if (ngx.var.cookie_token ~= token) then
  12.       return ngx.redirect("/auth?url=".. ngx.var.request_uri)
  13.     end
  14.   '; } location /auth { limit_req zone=auth_limit burst=1; if ($arg_url = "") { return 403; } access_by_lua '
  15.       local random = math.random(9999)
  16.       local token = ngx.md5("opencdn" .. ngx.var.remote_addr .. random)
  17.       if (ngx.var.cookie_token ~= token) then
  18.         ngx.header["Set-Cookie"] = {"token=" .. token, "random=" .. random}
  19.         return ngx.redirect(ngx.var.arg_url)
  20.       end
  21.     '; }
  22. 我想大家也应该已经猜到,这段配置文件的原理就是:把本来的发token的功能分离到一个auth页面,然后用limit对这个auth页面进行频率限制即可。这边的频率是1个IP每分钟授权1个token。当然,这个数量可以根据业务需要进行调整。

  23. 需要注意的是,这个auth部分我lua采用的是access_by_lua,原因在于limit模块是在rewrite阶段后执行的.
复制代码





------------------------------------------------------------------------------------------------------------------------------
Starting nginx... nginx: [emerg] invalid number of arguments in "limit_req_zone" directive in /usr/local/nginx/conf/nginx.conf:57
重启nginx 后报这个错误  (nginx 1.10.1)

[ 本帖最后由 依剑听雨 于 2016-7-1 14:02 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-7-1 15:04:40 | 显示全部楼层

回复 7# 的帖子


nginx的limit_req模块只能有一个变量
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2017-5-4 18:19:08 | 显示全部楼层

回复 5# 的帖子



make[1]: *** [objs/addon/src/ngx_http_lua_headers.o] Error 1
make[1]: Leaving directory '/root/lnmp1.4/src/nginx-1.13.0'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
cp: cannot stat ‘objs/nginx’: No such file or directory
Test nginx configure file...
include/upgrade_nginx.sh: line 59: /usr/local/nginx/sbin/nginx: No such file or directory
upgrade...
/usr/local/nginx/sbin/nginx -t
make: /usr/local/nginx/sbin/nginx: Command not found
Makefile:17: recipe for target 'upgrade' failed
make: *** [upgrade] Error 127
Checking ...
Error: Nginx upgrade failed.

照着这个教程升级Nginx依然是这个错误!

军哥运维代购:http://shop63846532.taobao.com/

发表于 2017-5-4 21:49:33 | 显示全部楼层

回复 9# 的帖子




教程没有问题,看不到具体错误没法说,也可能你操作步骤上有问题或有其他问题
无法解决可以联系qq或旺旺付费安装
发表于 2021-8-12 09:10:02 | 显示全部楼层

licess 发表于 2017-5-4 21:49
教程没有问题,看不到具体错误没法说,也可能你操作步骤上有问题或有其他问题
无法解决可以联系qq或旺旺付 ...

在哪里可以看到  比方说 nginx 1.6 用 LuaJIT-2.0.4,nginx 1.7 用其他的包?就是他们的对应关系
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-4-24 23:15 , Processed in 0.029727 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表