026_nginx引用lua遇到的坑
server {
listen 80;
listen 443 ssl;
server_name www.jyall.com;
access_log /data/log/nginx/*.www.jyall.com.access.log ngx_main;
error_log /data/log/nginx/*.www.jyall.com.error.log;
charset utf-8;
underscores_in_headers on;
ssl_certificate ssl/jyall.crt;
ssl_certificate_key ssl/*.www.jyall.com-2018-07-29.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
error_page 400 401 402 403 404 406 = /error404.html;
location = /error404.html {
root /opt/nginx/html;
}
error_page 500 502 503 504 = /error500.html;
location = /error500.html {
root /opt/nginx/html;
}
location ~ ^/get_json {
default_type application/json;
return 200 '{"status":"success","result":"nginx json3"}'; #json测试
}
}
二、
]$ sudo luarocks list
Installed rocks:
----------------
lua-resty-iputils
0.3.0-1 (installed) - /usr/local/lib/luarocks/rocks
luasocket
3.0rc1-2 (installed) - /usr/local/lib/luarocks/rocks
lyaml
6.1.1-4 (installed) - /usr/local/lib/luarocks/rocks
]$ sudo luarocks remove luasocket
]$ sudo vim nginx.conf
error_log /data/log/nginx/error.log debug #把debug日志打开
]$ sudo /opt/nginx/sbin/nginx -t
the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: [error] init_by_lua_file error: /opt/nginx/conf/lua/resty/influxdb.lua:9: module 'socket' not found:
no field package.preload['socket']
no file '/opt/nginx/conf/lua/socket.lua'
no file './socket.lua'
no file '/usr/local/share/luajit-2.0.4/socket.lua'
no file '/usr/local/share/lua/5.1/socket.lua'
no file '/usr/local/share/lua/5.1/socket/init.lua'
no file '/opt/nginx/conf/lua/socket.so'
no file './socket.so'
no file '/usr/local/lib/lua/5.1/socket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/opt/nginx/conf/lua/resty/influxdb.lua:9: in main chunk
[C]: in function 'require'
/opt/nginx/conf/lua/init_by_lua.lua:25: in main chunk
configuration file /opt/nginx/conf/nginx.conf test failed
]$ sudo /opt/nginx/sbin/nginx -s reload #但是照样可以reload,而且日志没有任何报错
]$ sudo /opt/nginx/sbin/nginx -d #下边的原先为json改为json3后内存内容也进行了更新
location ~ ^/get_json {
default_type application/json;
return 200 '{"status":"success","result":"nginx json3"}';
}
}
nginx: [error] init_by_lua_file error: /opt/nginx/conf/lua/resty/influxdb.lua:9: module 'socket' not found:
no field package.preload['socket']
no file '/opt/nginx/conf/lua/socket.lua'
no file './socket.lua'
no file '/usr/local/share/luajit-2.0.4/socket.lua'
no file '/usr/local/share/lua/5.1/socket.lua'
no file '/usr/local/share/lua/5.1/socket/init.lua'
no file '/opt/nginx/conf/lua/socket.so'
no file './socket.so'
no file '/usr/local/lib/lua/5.1/socket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/opt/nginx/conf/lua/resty/influxdb.lua:9: in main chunk
[C]: in function 'require'
/opt/nginx/conf/lua/init_by_lua.lua:25: in main chunk ]$ sudo curl -H "Host:venus.jyall.com" "127.0.0.1/get_json" #但实际curl的时候还是最老的内容
{"status":"success","result":"nginx json"} 总结:(1)打开nginx debug(2)然后sudo /opt/nginx/sbin/nginx -t进行测试查询是否有问题(有问题需要及时修复)。
026_nginx引用lua遇到的坑的更多相关文章
- 在redis一致性hash(shard)中使用lua脚本的坑
redis 2.8之前的版本,为了实现支持巨量数据缓存或者持久化,一般需要通过redis sharding模式来实现redis集群,普遍大家使用的是twitter开源的Twemproxy. twemp ...
- Java引用外部字体(路径引用)的一些坑
一 原因 后端负责字体...哎,我们公司的前端真的任性啊... 然后,一路踩了jvm关于字体的坑,重点是,java的报错很随意,甚至不报错,建议直接看最后面. 二 代码 正常要windows装一次字体 ...
- lua中的坑
在工作中使用lua也有一年了,代码也写了不少,踩过不少坑,这里记录一下. table.sort table.sort是lua自带的排序函数,数据量小时,也还是不错的.不过要注意你传入的compare函 ...
- lua 基础 之 坑一样的地方
-- local 局部-- local表=全局表,是同一个表,这主要是由于lua的表机制是匿名的,相当于函数的指针,local foo = foo,-- 即使本地foo没有在全局_G注册,还是引用的是 ...
- redis Lua学习与坑
1.在写lua脚本往redis中添加zadd 有序集合的时候一直报 "value is not a valid float"的错误,经过查询相关资料,最后发现,是顺序写反了. 相关 ...
- android 解决studio生成aar包并在其他工程引用aar包的坑,不需要任何gradle配置
1.首先我们创建一个module 2.编写我们的一个类 3.编译我们的module,生成release版本的aar,注意千万不要是debug版本的, 点击最右边的gradle面板,选择我们的modul ...
- 【原创】面向对象作业:选课系统中用pickle储存多个对象间组合引用关系的那些坑
转载请注明出处:https://www.cnblogs.com/oceanicstar/p/9030121.html 想直接看结论先提前列出: 1.存储一个对象,文件不是真的给你存储的了对象这种东西, ...
- gradle 多模块Springboot项目 compile project引用其他模块的坑
本来以为子项目中compile project(':xxx'),就能引用其他模块了,因为之后idea也没在引用时候标红 然而我gradle build的时候,居然各种找不到引用模块的类 最后在stac ...
- PHP循环引用会遇到的坑
今天遇到这样一个问题: 如果foreach循环一个数组,引用去对它的元素做一些操作,会有什么问题吗? 比如 [1, 2, 3],foreach循环的时候,引用给每个元素 * 2,再去foreach输出 ...
随机推荐
- ipython介绍及使用
1. IPython介绍 ipython是一个python的交互式shell,比默认的python shell好用得多,支持变量自动补全,自动缩进,支持bash shell命令,内置了许多很有用的功能 ...
- 【leetcode-100】 简单 树相关题目
100. 相同的树 (1过,熟练) 给定两个二叉树,编写一个函数来检验它们是否相同. 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的. 示例 1: 输入: 1 1 / \ / \ 2 ...
- bzoj千题计划323:bzoj1951: [Sdoi2010]古代猪文(Lucas+CRT+欧拉定理)
https://www.lydsy.com/JudgeOnline/problem.php?id=1951 先欧拉降幂 然后模数质因数分解 分别计算组合数的结果,中国剩余定理合并 #include&l ...
- idea上使用maven模块开发
使用maven模块开发: 使用Maven构建多模块项目 在平时的Javaweb项目开发中为了便于后期的维护,我们一般会进行分层开发,最常见的就是分为common(域模型层).dao(数据库访问层).s ...
- CodeMirror 在线代码编辑器
像百度编辑器插件部分.菜鸟教程示例等高德地图都在使用,这里也记录一下: CodeMirror是一个用于编辑器文本框textarea代码高亮javascript插件...... vue 中使用 参见:h ...
- TCP回射服务器修订版(ubuntu 18.04)
一.需求 把https://www.cnblogs.com/soldierback/p/10673345.html中的TCP回射服务器程序重写成使用select来处理任意个客户的单进程 程序,而不是为 ...
- GIT好文搜藏
git图解:代码区域总结 https://zhuanlan.zhihu.com/p/20175919 git跟传统的代码管理器(如:svn)不同, 主要区别在于git多了个本地仓库以及缓存区,所以即使 ...
- React 体验
https://github.com/facebook/create-react-app npm i -g create-react-app cd <your-folder> creat ...
- Dapper.net Insert mssql unicode 乱码问题
1.效果: 2.处理方法: /// <summary> /// insert single sql /// </summary> /// <typeparam name= ...
- Nginx 关闭日志生成文件
nginx 关闭日志:其实一种方法就是写入/dev/null 文件 或者设置关闭: nginx 日志有两个类型 access.log http 记录访问日志. error.log server ...