如何配置lua的WEB运行环境?

ptlzx 2008-11-03 07:03:16
我的系统是windows 2008,现在有一个WEB应用程序,里面包含大量的lua、js、html及几个DLL文件,请问要如何在IIS7中配置该网站的运行环境?
请给出具体的设置办法和支持配置程序的下载地址,谢谢!

另外问一下。DLL文件在IIS7中要特别设置运行环境步骤吗?
...全文
622 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ngwsx 2011-08-05
  • 打赏
  • 举报
回复

注:最新版本在以下博客首发:
http://blog.csdn.net/ngwsx/


ngx_lua_module是一个nginx http模块,它把lua解析器内嵌到nginx,用来解析并执行lua语言编写的网页后台脚本。


更新说明:
*) 更改LUA表的名称,具体如下:

nginx.dbd变成nginx.database;

nginx.log变成nginx.logger;

nginx.req变成nginx.request;

nginx.resp变成nginx.response;

nginx.var变成nginx.variable。

*) 重新实现nginx.database表,原有函数全部去掉,新增execute函数,

简化了LUA代码中的数据库操作。具体请查看下面示例代码的用法。

*) ngx_lua_module模块核心代码的优化。


特性:

*) HTML网页中内嵌LUA脚本代码,类似于PHP。

*) 支持非阻塞的数据库操作,目前只支持MYSQL。


API说明:

*) nginx 表

*) nginx.database 表

提供数据库操作的接口,这些接口的内部实现是基于非阻塞模式的,

因此不会阻塞Nginx的事件处理,可以支持比较高的并发。

具体用法请查看下面的示例代码。

*) nginx.logger 表

Nginx日志接口的封装,允许在LUA代码写日志信息到Nginx的日志文件中。

具体用法请查看下面的示例代码。

*) nginx.request 表

提供与HTTP请求有关的接口,可以获取请求参数、请求头和Cookie值。

具体用法请查看下面的示例代码。

*) nginx.response 表
提供与HTTP响应有关的接口。

具体用法请查看下面的示例代码。

*) ngnx.variable 表

提供接口给LUA代码以获取Nginx的HTTP变量。

具体用法请查看下面的示例代码。


TODO:

*) API说明文档。

*) 更多实用功能的LUA表和接口实现,

例如多台机器之间会话(Session)共享的透明处理。


最新版本:

windows:https://github.com/downloads/hehaiqiang/ngwsx/ngx_lua_module-windows-1.0.5.1.rar
linux:(暂无)


历史版本:
https://github.com/hehaiqiang/ngwsx/downloads


示例代码:

index.lsp

<%
local req = nginx.request

--local name = req["name"]
--local name = req.name

if req.method == req.GET then
name = req.get["name"]
name = req.get.name
else
name = req.post["name"]
name = req.post.name
end

name = name or "world"
%>
<html>
<head><title>hello, <%=name%>!</title></head>
<body>
hello, <%=name%>!
<hr>
<form action="index.lsp" method="post">
<input type="text" name="name"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>


test_database.lsp

<%
local print = print
local nginx = nginx
local req = nginx.request
local db = nginx.database

local res = db.execute({
driver = "libdrizzle",
host = "127.0.0.1",
port = 3306,
user = "root",
password = "123456",
database = "mysql",
sql = "show databases"
})
%>
<html>
<head>
</head>
<body>
err: <%=res.err%>
<br/>
errstr: <%=res.errstr%>
<br/>
col_count: <%=res.col_count or ""%>
<br/>
row_count: <%=res.row_count or ""%>
<br/>
affected_rows: <%=res.affected_rows or ""%>
<br/>
insert_id: <%=res.insert_id or ""%>
<br/>
<% if res.err ~= 0 then print("error") return end %>
<hr>
<table border="1">
<tr>
<% for i=1,#res.columns do %>
<td><b><%=res.columns[i]%></b></td>
<% end %>
</tr>
<% for r=1,#res.rows do %>
<tr>
<% for i=1,#res.rows[r] do %>
<td><%=res.rows[r][i]%></td>
<% end %>
</tr>
<% end %>
</table>
<hr>
request_time: <%=req.request_time%>ms
</body>
</html>


test_logger.lsp

<%
local print = print
local nginx = nginx
local log = nginx.logger
%>
<html>
<head>
</head>
<body>
<%
-- writing some messages into the log file of the nginx
log.error(log.ALERT, "test alert" .. 1 .. 10)
log.debug(log.DEBUG_HTTP, "test debug http")
log.error(log.ERR, "test error")
log.error(log.EMERG, 1000)
%>
please opening the log file of the nginx to view messages.
</body>
</html>


test_request.lsp

<%
local print = print
local nginx = nginx
local req = nginx.request

local get_req_members = function()
return {
uri = req.uri,
args = req.args,
host = req.host,
exten = req.exten,
method = req.method,
referer = req.referer,
user_agent = req.user_agent,
method_name = req.method_name,
request_time = req.request_time .. "ms",
request_line = req.request_line,
unparsed_uri = req.unparsed_uri,
http_protocol = req.http_protocol
}
end

function get_headers_members()
local headers = req.headers
return {
host = headers.host,
user_agent = headers.user_agent
}
end
%>
<html>
<head>
</head>
<body>
<table border="1">
<% for k,v in pairs(get_req_members()) do %>
<tr><td><%=k%></td><td><%=v%></td></tr>
<% end %>
</table>
<hr>
<table border="1">
<% for k,v in pairs(get_headers_members()) do %>
<tr><td><%=k%></td><td><%=v%></td></tr>
<% end %>
</table>
<%
-- TODO: test the table "req.cookies"
%>
<hr>
<%
local one = req["one"] or 1
local two = req.two or 2
local three = req.get["three"] or 3
local four = req.get.four or 4
%>
hello, <%=one%><%=two%><%=three%><%=four%>!
</body>
</html>


test_response.lsp

<%
local print = print
local nginx = nginx
local req = nginx.request
local resp = nginx.response
resp.content_type = "text/html"
%>
<html>
<head><title></title></head>
<body>
<%
local one = req["one"] or 1
local two = req.two or 2
local three = req.post["three"] or 3
local four = req.post.four or 4
%>
hello, <%=one%><%=two%><%=three%><%=four%>!
<hr>
<form action="test_response.lsp" method="post">
<input type="text" name="one"/>
<input type="text" name="two"/>
<input type="text" name="three"/>
<input type="text" name="four"/>
<input type="submit" value="submit"/>
</form>
<hr>
</body>
</html>


test_variable.lsp

<%
local print = print
local nginx = nginx
local var = nginx.variable
local array = {
--var.arg_PARAMETER or "",
args = var.args or "",
binary_remote_addr = var.binary_remote_addr or "",
body_bytes_sent = var.body_bytes_sent or "",
content_length = var.content_length or "",
content_type = var.content_type or "",
--var.cookie_COOKIE or "",
document_root = var.document_root or "",
document_uri = var.document_uri or "",
host = var.host or "",
hostname = var.hostname or "",
--var.http_HEADER or "",
user_agent = var.http_user_agent or "",
is_args = var.is_args or "",
limit_rate = var.limit_rate or "",
nginx_version = var.nginx_version or "",
query_string = var.query_string or "",
remote_addr = var.remote_addr or "",
remote_port = var.remote_port or "",
remote_user = var.remote_user or "",
request_filename = var.request_filename or "",
request_body = var.request_body or "",
request_body_file = var.request_body_file or "",
request_completion = var.request_completion or "",
request_method = var.request_method or "",
request_uri = var.request_uri or "",
scheme = var.scheme or "",
server_addr = var.server_addr or "",
server_name = var.server_name or "",
server_port = var.server_port or "",
server_protocol = var.server_protocol or "",
uri = var.uri or ""
}
%>
<html>
<head>
</head>
<body>
<%=#array%>
<hr>
<table border="1">
<% for k,v in pairs(array) do %>
<tr><td><%=k%></td><td><%=v%></td></tr>
<% end %>
</table>
</body>
</html>
iambic 2011-08-05
  • 打赏
  • 举报
回复
不知道你的项目是基于什么写的。
ngwsx 2011-08-05
  • 打赏
  • 举报
回复
ngx_lua_module-1.0.5.0 (LUA编写网页脚本,支持windows和linux)

http://blog.csdn.net/ngwsx/article/details/6648779
ptlzx 2008-11-05
  • 打赏
  • 举报
回复
我的安装步骤如下:
[1] install /SCRIPTS c:\luarocks\1.0
[2] luarocks install kepler-xavante
[3] setup-kepler
[4] xavante_start

(3〕、(4)步骤出问题:
(3)C:\luarocks>setup-kepler
命令语法不正确。
This is the Kepler 1.1 setup.
Kepler configuration: c:\LuaRocks\kepler/etc
Kepler web root: c:\LuaRocks\kepler/htdocs
Kepler apps: c:\LuaRocks\kepler/apps
Kepler logs: c:\LuaRocks\kepler/log
Kepler temp dir: c:\WINDOWS\Temp
Proceed with setup? [Y/n] y
C:\LuaRocks/rocks/kepler/1.1-1/lua/kepler_init.lua already exists, replace it? [
y/N] y
Writing C:\LuaRocks/rocks/kepler/1.1-1/lua/kepler_init.lua
命令语法不正确。
Copying configuration files to c:\LuaRocks\kepler/etc

(4)C:\luarocks-1.0>xavante_start
C:/LuaRocks/1.0/lua5.1: ...uaRocks/rocks//xavante/2.0.0-1/lua/xavante\httpd.lua:
354: permission denied
stack traceback:
[C]: in function 'assert'
...uaRocks/rocks//xavante/2.0.0-1/lua/xavante\httpd.lua:354: in function
'register'
C:\LuaRocks/rocks//xavante/2.0.0-1/lua/xavante.lua:85: in function 'HTTP
'
c:\LuaRocks\kepler/etc/xavante/config.lua:64: in function 'res'
...uaRocks/rocks/kepler-xavante/1.1-1/bin/xavante_start:58: in main chun
k
[C]: ?
ptlzx 2008-11-04
  • 打赏
  • 举报
回复
我在配置时出现如下两个错误:
1、C:\luarocks>setup-kepler
命令语法不正确。
This is the Kepler 1.1 setup.
Kepler configuration: c:\LuaRocks\kepler/etc
Kepler web root: c:\LuaRocks\kepler/htdocs
Kepler apps: c:\LuaRocks\kepler/apps
Kepler logs: c:\LuaRocks\kepler/log
Kepler temp dir: c:\WINDOWS\Temp
Proceed with setup? [Y/n] y
C:\LuaRocks/rocks/kepler/1.1-1/lua/kepler_init.lua already exists, replace it? [
y/N] y
Writing C:\LuaRocks/rocks/kepler/1.1-1/lua/kepler_init.lua
命令语法不正确。
Copying configuration files to c:\LuaRocks\kepler/etc

2、C:\luarocks>xavante_start
C:/LuaRocks/1.0/lua5.1: error loading module 'lfs' from file 'C:\LuaRocks/rocks/
/luafilesystem/1.4.1-1/lib/lfs.dll':
由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个
问题。
stack traceback:
[C]: ?
[C]: in function 'plain_require'
C:\LuaRocks\1.0\lua\luarocks\require.lua:165: in function <C:\LuaRocks\1
.0\lua\luarocks\require.lua:154>
(tail call): ?
...s/rocks//xavante/2.0.0-1/lua/xavante\filehandler.lua:10: in main chun
k
[C]: in function 'plain_require'
C:\LuaRocks\1.0\lua\luarocks\require.lua:165: in function <C:\LuaRocks\1
.0\lua\luarocks\require.lua:154>
(tail call): ?
c:\LuaRocks\kepler/etc/xavante/config.lua:19: in function 'res'
...uaRocks/rocks/kepler-xavante/1.1-1/bin/xavante_start:58: in main chun
k
[C]: ?

wx红杉树 2008-11-04
  • 打赏
  • 举报
回复
不需要,你参考老的配置方法吧

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧