luaIde 调试openresty
调试视频
提取码:o3rk
1.创建一个项目 如果已存在项目忽略
![5576301-5b5c16d948bcd662.png](https://upload-images.jianshu.io/upload_images/5576301-5b5c16d948bcd662.png)
image.png
2.项目中创建src目录
(src目录可是任意名字 示例中将src放入根目录中,您也可以放到其他目录,src目录为lua脚本根目录)
如果已存在项目忽略
![5576301-dca678f3fb4944a7.png](https://upload-images.jianshu.io/upload_images/5576301-dca678f3fb4944a7.png)
image.png
3.配置项目
![5576301-d1020353ea302c06.png](https://upload-images.jianshu.io/upload_images/5576301-d1020353ea302c06.png)
image.png
前三步可以忽略根据自己的项目来定即可.
4.用vscode 打开项目文件夹 示例中的项目文件夹为openresty_test
5.打开一个lua文件以启动luaide插件(演示中没有lua文件,所以创建一个文件 test.lua)
6.根据提示将调试文件拷贝到src目录中
选择LuaDebugOpenrestyJit 后缀选择.lua
由于luaide支持多种lua框架的调试所以会有很多不同的后缀名,openresty 选择.lua即可
这一步操作后 LuaDebugOpenrestyJit.lua 拷贝到src 下
![5576301-4456533346eae0c5.png](https://upload-images.jianshu.io/upload_images/5576301-4456533346eae0c5.png)
第一步
![5576301-59388f57fbbb8864.png](https://upload-images.jianshu.io/upload_images/5576301-59388f57fbbb8864.png)
第二步
![5576301-bc2875232c12fca1.png](https://upload-images.jianshu.io/upload_images/5576301-bc2875232c12fca1.png)
选择目录进行添加调试文件
![5576301-a5457d628d46c5f0.png](https://upload-images.jianshu.io/upload_images/5576301-a5457d628d46c5f0.png)
openresty
![5576301-a2025d9c643082d2.png](https://upload-images.jianshu.io/upload_images/5576301-a2025d9c643082d2.png)
![5576301-dd4e9f1692432e46.png](https://upload-images.jianshu.io/upload_images/5576301-dd4e9f1692432e46.png)
7.点击vscode左侧luaide按钮选择[打开luaide最新调试文件所在文件夹]
![5576301-3eab26e2d748ce1d.png](https://upload-images.jianshu.io/upload_images/5576301-3eab26e2d748ce1d.png)
![5576301-c2859c21ce6d017a.png](https://upload-images.jianshu.io/upload_images/5576301-c2859c21ce6d017a.png)
拷贝文件
linux 找到socketLib\OpenResty\linux目录下的 socket.so 拷贝到openresty_test(项目根目录)
mac 找到socketLib\OpenResty\mac目录下的 socket.so 拷贝到openresty_test(项目根目录)
windows 找到socketLib\OpenResty\windows目录下的 socket.so 拷贝到openresty_test\lualib(项目根目录\lualib)
8.在luaide配置中设置脚本根目录 选择settings(中文为设置)
搜索luaide.scriptRoots 并进行设置 然后重启vscode
这里注意vscode 的设置配置分为
1.用户设置
2.工作空间设置 示例中添加到了 工作空间设置 设置后重启vscode f1 reloadwindow
3.文件夹设置
修改配置后重启vscode f1 reload window
![5576301-98fc7ff4810974e7.png](https://upload-images.jianshu.io/upload_images/5576301-98fc7ff4810974e7.png)
设置脚本根目录
9.添加调试代码以启动调试
![5576301-86c30a59ad0ffa49.png](https://upload-images.jianshu.io/upload_images/5576301-86c30a59ad0ffa49.png)
image.png
10.添加调试配置
![5576301-8fd50e45102d54ba.png](https://upload-images.jianshu.io/upload_images/5576301-8fd50e45102d54ba.png)
添加调试配置
![5576301-96bdd4bdfd3945e0.png](https://upload-images.jianshu.io/upload_images/5576301-96bdd4bdfd3945e0.png)
添加lua调试
![5576301-bbb75daf3f2c4af0.png](https://upload-images.jianshu.io/upload_images/5576301-bbb75daf3f2c4af0.png)
选择调试模式
![5576301-8be2b322b6121be1.png](https://upload-images.jianshu.io/upload_images/5576301-8be2b322b6121be1.png)
启动调试
11.启动调试 nginx -p pwd
/ -c conf/nginx.conf (启动调试根据自己项目情况自行启动.这里只是演示)
12.访问页面
![5576301-5551ffc2b310a879.png](https://upload-images.jianshu.io/upload_images/5576301-5551ffc2b310a879.png)
image.png
调试演示结束!
转载于:https://www.jianshu.com/p/070870d43368