openresty是一个基于nginx+lua的高性能web平台。
一、openresty的安装
1、linux下安装
(1)下载源码
建议从官方下载最新稳定版代码:https://openresty.org
wget https://openresty.org/download/openresty-1.9.7.4.tar.gz
(2)编译安装
tar -zxvf openresty-1.9.7.4.tar.gz
cd openresty-1.9.7.4
./configure --prefix=/usr/local/openresty
make && make install
2、windows下安装
下载解压即可:http://openresty.org/cn/download.html
注:在windows下启动openresty最好通过cmd命令行,而不是通过双击nginx.exe文件
如,我把openresty安装在E:/devtools/openresty下
E:
cd devtools/openresty
nginx
3、启动并测试
/usr/local/openresty/nginx/sbin/nginx
写一个helloworld程序测试是否安装成功:
在openresty下的nginx配置文件中添加一行location
location /helloworld {
default_type text/html;
content_by_lua_block {
ngx.say("hello,openresty!");
}
}
然后重启nginx(注意是openresty安装目录下的nginx,如果nginx没有启动,直接启动即可)
在浏览品中访问:http://{{ip}}/helloworld
(此处将IP换成您的服务器IP,如我本地的:http://192.168.1.201/helloworld
)
如果在浏览器中显示:hello,openresty!则说明成功了
二、openresty开发环境搭建及学习资料
1、编辑器
目前并没有发现很好的openresty的编辑器,只能通过sublime+插件的形式来开发openresty。非常感谢sublime的lua和openresty插件的开发者。
(1)sublime
从sublime官方下载sublime text2或者sublime text 3
注:安装sublime插件需要先安装package control的插件,安装方法见:https://packagecontrol.io/installation#st2
(2)sublime的lua插件
安装package control插件后,可以在菜单Tools->Build System子菜单中选择Lua或Luajit即可
(3)sublime的openresty插件
https://github.com/membphis/openresty_lua_snippets
安装方法:
从github下载openresty插件
打开sublime编辑器,选择菜单中的:Perferences->Browse Packages进入sublime的插件目录
将openresty插件放入sublime包目录即可
2、学习社区
(1)openresty官方网站:http://openresty.org
(2)openresty的github:
http://github.com/openresty/openresty(3)openresty基金会官方社区:http://bbs.iresty.com
(4)openresty china社区:http://orchina.org/
(5)openresty基金会iresty组织github:http://github.com/iresty
(6)openresty创始人春哥的新浪微博:
http://weibo.com/agentzh
3、学习资料
(1)openresty官方文档及iresty编译的中文文档:
https://github.com/iresty/nginx-lua-module-zh-wiki
(2)iresty组织撰写的电子书:openresty最佳实践
https://github.com/moonbingbing/openresty-best-practices
(3)春哥撰写的电子书:programing openresty
https://github.com/openresty/programming-openresty
(4)openresty web框架 香草vanilla
https://github.com/idevz/vanilla
(5)lua编程书籍
programming in lua