SnowLeopard
kepler-avanter在windows下安装很easy(虽然也出了一个小问题,就是路径名,windows下是'/',而unix风格下是'/',改下lua代码就可以了),但在snowLeopard下安装费了很大的力气。
最后发现是我下的luarocks版本不对,luarocks2.0和luarocks2.0.1版本在MacOS也有问题,最后下来1.0版本才解决。
步骤:
1:到http://luarocks.org/releases/下载 luarocks-1.0.tar.gz
2: 进入luarocks解压目录
./configure
make
make install
3: sudo luarocks install kepler-xavante KEPLER_WEB=/usr/local/www
另,几个小技巧:
1:让ls在termal下显示颜色,在/private/etc/profile末尾加入:
alias ls='ls -G'
2: 进入su
sudo su - root
Windows
1: 下载lua并安装: http://code.google.com/p/luaforwindows/
2: 下载luarocks: http://luarocks.org/releases/luarocks-2.0.2-lfw.zip
3: 将下载包解压到lua安装目录,默认在C:/Program Files/Lua/5.1
4: 打开dos终端,运行
luarocks install wsapi-xavante
luarocks install cgilua
5: 创建一个目录,用于存放网页数据,比如说d:/htdocs
6: 在d:/htdocs下新建一个文件 config.lua,内容请见后面
7: 在d:/htdocs下创建一个文件 start_kepler.bat,内容为:
wsapi --cgilua --config=config.lua
以后如果需要启动kepler,运行start_kepler.bat即可
config.lua内容如下:
-- $SYSCONFDIR/kepler/1.1/xavante/config.lua
require "xavante.filehandler"
require "xavante.redirecthandler"local function makerules(webDir)
return {
{ -- URI remapping example
match = "^[^%./]*/$",
with = xavante.redirecthandler,
params = {"index.lp"}
},{ -- wsapihandler example
match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
with = wsapi.xavante.makeGenericHandler (webDir, launcher_params)
},{ -- wsapihandler example
match = {"%.ws$", "%.ws/" },
with = wsapi.xavante.makeGenericHandler (webDir, launcher_params)
},{ -- filehandler example
match = ".",
with = xavante.filehandler,
params = { baseDir = webDir }
},}
end-- Displays a message in the console with the used ports
xavante.start_message(function (ports)
local date = os.date "[%Y-%m-%d %H:%M:%S]"
print(
("%s Xavante started on port(s) %s"):format(
date,
table.concat(ports, ", ")
)
)
end)xavante.HTTP {
server = { host = "*", port = 80 },defaultHost = {
rules = makerules(XAVANTE_WEB)
},--virtualhosts = {
-- ["www.client1.com"] = { rules = makerules "/home/client1" },
-- ["www.client2.com"] = { rules = makerules "/home/client2" },
-- ["www.client3.com"] = { rules = makerules "/home/client3" },
--},
}