使用ZeroBrane Studio调试Openresty lua脚本

本文介绍如何利用ZeroBrane Studio IDE进行OpenResty的Lua脚本开发与调试。涵盖安装步骤及示例配置,帮助开发者快速上手。

介绍

ZeroBraneStudio 作为轻量级、跨平台的Lua IDE,已被广泛用来调试各种Lua引擎游戏框架、Openresty、Wireshark脚本等等。

Openresty 是一个建立在Nginx Web应用服务器,一个非常快的Web服务器,提供非阻塞IO(各种后端redis、memcached、MySQL、HTTP服务器等)和支持Lua作为其脚本语言。


目的

本文旨在帮助初涉Openresty开发的相关开发人员了解如何使用ZeroBraneStudio开发和调试自己的lua脚步

如下按照2个步骤说明:

1、安装Openresty和ZeroBrane Studio

2、编写简单Openresty脚步并进行调试


安装Openresty和ZeroBrane Studio

1、Openresty安装

Openresty提供多种安装方式(http://openresty.org/cn/installation.html),在unix系统上我们可以直接使用官方提供的预编译包直接安装,使用windows的同学可以直接下载exe运行(http://openresty.org/cn/download.html)。

2、ZeroBraneStudio安装

从https://github.com/pkulchenko/ZeroBraneStudio/releases下载发布包并解压,运行zbstudio.exe or zbstudio.sh打开ZeroBraneStudio,同时点击Project->Project Directory选择Openresty目录。


编写简单Openresty脚步并进行调试

我们首先更改openresty配置如下:

worker_processes  auto;

worker_rlimit_nofile 65535;

events {
    worker_connections 20480;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    limit_req_zone $binary_remote_addr zone=one:50m rate=20r/s;

    lua_package_path 'D:\ZeroBraneStudio-1.70/lualibs/?/?.lua;D:\ZeroBraneStudio-1.70/lualibs/?.lua;;';
    lua_package_cpath 'D:\ZeroBraneStudio-1.70/bin/clibs/?.dll;;';
    
    include server.conf;
}
    server {
        listen 80;


        location /helloworld {
            default_type text/plain;
            content_by_lua_file D:\openresty-1.13.6.1-win32\lua\content.lua;
        }
    }

然后运行nginx.exe启动Openresty,点击Project | Start Debugger Server启动Debugger Server,在浏览器输入http://localhost/helloworld,然后即可进入断点调试

(If you are running on OSX, replace ?.dll with ?.dylib and if you are running on Linux, replace bin/clibs/?.dll with either bin/linux/x86/clibs/?.so or bin/linux/x64/clibs/?.so depending on your platform.)

转载于:https://www.cnblogs.com/caozhiyuan/p/9425088.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值