One working solution – Lua wsapi with nginx in debian/ubuntu

You need to install luarocks, nginx before followin steps, and should run as root.

1) luarocks install wsapi-xavante

Then find the wsapi command, in my installation, it is under /usr/local/bin/wsapi

it is a shell script, looks like:

https://gist.github.com/715624

2) try to create one lua folder in your nginx content folder, such as “/var/www/nginx-default/” or “/usr/local/nginx/html/”

For example, if your folder is /var/www/nginx-default/lua, change current directory to this folder, write one lua file, name is “hello.lua”:

https://gist.github.com/715632

You could find reference how to write wsapi lua in

http://keplerproject.github.com/wsapi/manual.html

3) run command: /usr/local/bin/wsapi –p 8085

Opening browser and go to http://127.0.0.1:8085/hello.lua 

You should able to see:

Hello Wsapi!

PATH_INFO: /

SCRIPT_NAME: /hello.lua

4) change nginx.conf, add following:

location ~ \.lua$ {

        proxy_pass   http://127.0.0.1:8081;

}

5) pkill lua, then run “/usr/local/bin/wsapi –p 8085 &” in folder /var/www/nginx-default/lua

Restart nginx.

6) go to http://127.0.0.1/hello.lua, it should work now.

发表评论