用lua实现的基于openresty的简单的WEB API框架[其实不算一个框架,只是把多个开源的框架按需合一块便于小项目方便的使用]。(我们实际项目目前都是比较简单的接口,就需要按照不同项目把一些并发高的接口移植到openresty上,大多接口还是使用原来的PHP,所以项目是PHP和lua混编的项目,于是就有了luas)
当然了,首先安装openresty,这个就不解释了
下载项目放到服务器硬盘上,如:/data/www/lua/;在nginx.conf的http区块加上
lua_package_path '/data/www/lua/?.lua;;';
init_by_lua_file '/data/www/lua/init.lua';
创建server区块
server {
listen 80;
server_name www.demo.com;
charset utf-8;
error_log /var/log/openresty/www.demo.com_error.log debug;
access_log /var/log/openresty/www.demo.com_access.log;
index index.html index.php;
root /data/www/php/;
set $APP_NAME 'demo';
location / {
index index.php index.html index.luaphp;
}
location ~ \.php$ {
default_type text/html;
lua_code_cache off;
access_by_lua_file /data/www/lua/demo/main.lua;
fastcgi_pass php-fcgi;
include fastcgi.conf;
}
}
####结构
lua
init.lua --nginx启动的时候初始化
luas.conf --nginx配置样例
luas --框架
demo --demoluas/core --常用的库
luas/utils --工具类
demo/main.lua --项目入口文件
demo/config --项目配置文件夹
demo/components --项目自己的组件
demo/controller --项目控制器
luas/core/Debug.lua --debug库
luas/core/Request.lua --请求库
luas/core/Response.lua --响应库
luas/core/Route.lua --路由库
luas/core/SMysql.lua --mysql链接池
luas/core/SRedis.lua --redis链接池
luas/utils/IO.lua --IO工具
luas/utils/String.lua --字符串工具
luas/utils/Table.lua --TABLE工具
luas/utils/Utils.lua --常用的工具
demo/config/config.lua --项目配置文件
demo/controller/TestController.lua --项目测试控制器
demo/controller/RedisController.lua --项目测试redis
demo/components/hello.lua --项目测试组件