[nginx] nginx + spawn-fcgi + wsapi/lua(搭建lua的web dev平台)
来源:互联网 发布:yum y什么意思 编辑:程序博客网 时间:2024/06/05 16:18
nginx, web server
spawn-fcgi, 一个 fastcgi wrapper
wsapi.fcgi, WSAPI是针对lua的web标准,wsapi.fcgi就是把fcgi请求变成wsapi协议。
FreeBSD 8.1
安装 wsapi-fcgi
/usr/ports/www/fcgi
# pkg_add -r fcgi-devkit
# luarocks install wsapi-fcgi
安装 spawn-fcgi
/usr/ports/www/spawn-fcgi
# pkg_add -r spawn-fcgi
启动 spawn-fcgi
spawn-fcgi -F 1 -s /var/run/nginx-fcgi.sock -P /var/run/nginx-fcgi.pid -U nobody -- /usr/local/bin/wsapi.fcgi
安装nginx
/usr/ports/devel/pcre
# pkg_add -r pcre
下载 nginx-0.8.54
# ./configure && gmake install
---------------- nginx.conf ----------------
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
server_name localhost;
location / {
fastcgi_pass unix:/var/run/nginx-fcgi.sock;
fastcgi_index hello.lua;
fastcgi_param SCRIPT_FILENAME /home/kasicass/sandbox/kepler/wsapi$fastcgi_script_name;
}
}
}
-----------------------------------------------
启动 nginx
# /usr/local/nginx/sbin/nginx
WSAPI Hello World Program
------------------ hello.lua ---------------------
#!/usr/bin/env wsapi.cgi
module(..., package.seeall)
function run(wsapi_env)
local headers = { ["Content-type"] = "text/html" }
local function hello_text()
coroutine.yield("<html><body>")
coroutine.yield("<p>Hello WSAPI!</p>")
coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
coroutine.yield("</body></html>")
end
return 200, headers, coroutine.wrap(hello_text)
end
---------------------------------------------------
然后通过浏览器访问:
http://127.0.0.1/hello.lua
碰到的问题
spawn-fcgi 中的 "-U nobody" 参数,让 spawn-fcgi 以 nobody 权限启动。否则 nginx worker (nobody权限) 无法正确 connect()。
http://serverfault.com/questions/101983/nginx-php-fastcgi-fails-how-to-debug
nginx.conf 配置中 "fastcgi_index hello.lua;" 让 127.0.0.1/ 的访问变成 127.0.0.1/hello.lua
参考资料
老外的一篇 lua + nginx + fastcgi 的配置资料
http://davelahn.com/lua-nginx-fastcgi-in-debian
nginx + fastcgi + spawn-fcgi + mysql
http://www.akii.org/ubuntu-9-10-install-nginx-fastcgi-spawn-fcgi-mysql-diary.html
nginx + fastcgi
http://huichen.org/2010/03/12/configure-fastcgi-for-nginx/
0 0
- [nginx] nginx + spawn-fcgi + wsapi/lua(搭建lua的web dev平台)
- nginx python spawn-fcgi Flup webpy搭建python的web环境
- nginx python spawn-fcgi Flup webpy搭建python的web环境
- Nginx + FastCgi + Spawn-fcgi + C 架构的服务器环境搭建
- nginx[+spawn-fcgi]+flup+webpy服务搭建
- nginx+spawn-fcgi+flup+webpy服务搭建
- nginx[+spawn-fcgi]+flup+webpy服务搭建
- nginx+spawn-fcgi安装
- 使用Nginx+Lua搭建AB测试平台
- nginx+spawn-fcgi+demo+fcgi库函数
- nginx+spawn-fcgi+demo+fcgi库函数
- 详解nginx+spawn-fcgi+demo+fcgi库函数
- [转]nginx[+spawn-fcgi]+flup+webpy服务搭建
- 分布式(1):nginx+spawn-fcgi+fchi + c++ 环境搭建
- nginx+lua+redis搭建
- nginx + lua环境搭建
- nginx + lua环境搭建
- nginx的lua开发环境搭建
- Eclipse快捷键大全
- 基于 OpenFlow 实现网络虚拟化
- 进职场记(一)--下山
- ajax-php总结
- getDrawingCache()=null的解决办法
- [nginx] nginx + spawn-fcgi + wsapi/lua(搭建lua的web dev平台)
- for循环与ajax
- JavaScript(二)-13-(全局方法&Number对象)
- Android学习JNI,使用C调用JAVA语言
- c++中32位64位操作系统基本数据类型字节大小
- Java常见面试题
- Struts2 一、 视图转发跳转
- 第一天(开始尝试实例和阅读博客了)
- js/jquery获取页面大小,滚动条位置,元素位置