XXX to do
Statische Seiten
root@armv5te:/srv/www/htdocs
/etc/lighttpd/lighttpd.conf
root@armv5te:/srv/www/htdocs# ls /var/log/lighttpd access.log error.log
- /srv/www/cgi-bin$ ls
configs.tar.gz hello hello.c hello.cgi hello.pl hello.py README
- /etc/lighttpd/modules.conf
- include "conf.d/cgi.conf"
- server.modules = (
- "mod_access",
- # "mod_cgi",
"mod_alias",
...
/etc/lighttpd/conf.d/cgi.conf, drei Zeilen am Ende hinzunehmen:
- ...
alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" ) $HTTP["url"] =~ "^/cgi-bin" {
cgi.assign = ( "" => "" ) }
- hhoegl@aspire1:~$ ping 10.11.12.2
PING 10.11.12.2 (10.11.12.2) 56(84) bytes of data. 64 bytes from 10.11.12.2: icmp_seq=1 ttl=64 time=1.86 ms 64 bytes from 10.11.12.2: icmp_seq=2 ttl=64 time=1.80 ms
Auf dem Notebook (10.11.12.1):
Dynamische Websites mit "haserl" (kann auch Lua)
Lua
- Beispiel
#! /usr/local/bin/lua
print [[ Content-Type: text/plain
Hello, world ]]
---
Beispiel:
#!/usr/bin/env lua require 'cgi' io.write("Content-type: text/plainrnrn") local filename = assert(cgi.GET.filename, "no filename specified") local file = assert(io.open(filename)) local content = assert(file:read"*a") io.write(content)
Kepler is a Web development platform. So what? There are many of those. What´s special about Kepler? It is implemented as a set of Lua components, so it offers the same advantages as Lua: it is Simple, Portable, Light and Extensible (SIMPLE) It runs under Windows, Linux, OSX and a number of other operating systems It allows the use of SQL, LDAP, XML, SOAP and other standards It is open source software and uses the same license as Lua
WSAPI, CGILua, Kepler
Beispiel: web-cgi/CGI.lua
Verwendung:
local CGI = require( "CGI" )
print( CGI ) print( CGI:request() ) print( CGI:request():url() ) print( CGI:response() )
CGI:log()( "Arghh!", 123, nil, true ) CGI:print()( "Hello?" ) CGI:print()( "World?" ) CGI:print()( "Anyone?", "There?" ) CGI:response():write( "Hello?", "Hello?" ) CGI:response():setCookie( "hello", "world" )
print( ( "<bla> & "oops"" ):encode() )
CGI:run( {} )
> I've had a look at Kepler, CGILua and WSAPI, but none of them explains > how to run simple Lua cgi applications from Apache.
Here is the method I prefer, using WSAPI with request and response objects:
#! /bin/bash /path/to/kepler/bin/wsapi.cgi require("wsapi.request") require("wsapi.response") return function (env)
local request = wsapi.request.new(env) local response = wsapi.response.new() response:write("<h1>Hello</h1>") for k,v in pairs(request.GET) do
response:write(k.." = "..tostring(v).."<br/>")end return response:finish()
end
Put this into hello.cgi in where you would put other CGI files, set the standard CGI permissions and access it like any CGI file. The fact that the body of the script is wrapped in a function may be a hassle for simple CGI, but the plus is that it allows you to use the exact same script with Xavante (just rename it hello.ws and put it in kepler/htdocs).
-- http://sputnik.freewisdom.org/
lighttpd Dokumentation
Seite des Autors: http://www.linuxtoys.org/
Mastering Ajax (1) http://www.ibm.com/developerworks/web/library/wa-ajaxintro1/index.html
vim: syntax=off