Archive for June, 2008

Trying out mod_wombat, an in-development LUA Module for Apache2

I’m finally trying to setup mod_wombat:

sudo apt-get install apache2-threaded-dev liblua5.1-0-dev libapreq2-dev
cd /usr/src/
svn co http://svn.apache.org/repos/asf/httpd/mod_wombat/trunk/ ./mod_wombat
cd ./mod_wombat
./buildconf
./configure --with-mpm=worker --enable-so --with-apxs=/usr/bin/apxs2 --with-apreq2=/usr/

Some configure warnings, but then make gives an error:

/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static i486-linux-gnu-gcc -prefer-pic -DLINUX=2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread     -I/usr/include/apache2  -I/usr/include/apr-1.0   -I/usr/include/apr-1.0 -I/usr/include/postgresql -Wall -Werror -I/usr//include/apreq2 -I/usr/include/lua5.1  -c -o config.lo config.c && touch config.slo
config.c:197:2: error: no newline at end of file
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wombat.la] Error 1

I added “;\n” to the end, ( a real newline ), and it compiled. With a sudo make install, seems to be OK. I just tried out the Hello World example, and it worked!

Hello Lua World!

I couldn’t get the script to execute in a non-public directory, but I didn’t go through the configuration directives with a fine toothed comb. This is a great little tool, it bridges the gap between mod_rewrite / varnish and mod_perl / aolserver. :-)

NOTE: I’ve got to remember that Lua is also used with mysql_proxy.

If this is something that you are interested in, you might want to check out the work Maxime Petazonni is doing for the Google Summer of Code.

Other external links:
http://lua-users.org/wiki/LuaXml
http://asbradbury.org/projects/lua-xmlreader/

Varnish URL Rewriting

Varnish the reverse proxy can do some pretty cool stuff. I just realized that it compiles its VCL rules into C so that they are process quite efficiently. Here’s a few examples:

Route to a different backend based upon location (i.e. url):

backend server1 {
    set backend.host = "192.168.222.222";
    set backend.port = "80";
}

sub vcl_recv {
    if (req.url ~ "^/location-url") {
        set req.backend = server1;
        set req.http.host = "www.example.com";
    }
}

Explanation: when a client requests the url “/location-url” from varnish, it “routes” the request server1, which is located at the ip address 192.168.222.222, and uses the http host name www.example.com.

Backend choice with a traditional rewrite:

backend server1 {
    set backend.host = "192.168.222.222";
    set backend.port = "80";
}

sub vcl_recv {
    if (req.url ~ "^/location-url") {
        set req.backend = server1;
        set req.url = regsub(req.url, "^/location-url", "/url-location");
        set req.http.host = "www.example.com";
    }
}

Explanation: this is the same example, but the request prefix is changed from location-url to url-location. Pretty nifty, huh?

Python Beaker




Python’s Beaker package is actually quite nice. After wrestling with sessions in perl for awhile, its refreshing to find a package that “just works”.

I’ll have to research SQLAlchemy some more, because I still am having a hard time working with python db-api. I get the feeling though that SQLAlchemy makes databases “pythonic”, kind of like how lxml handles libxml2. I haven’t bought into that concept yet, I’m a big fan of SQL “as-is”, in my opinion there is no need to change it at the moment.

Chances are I’ll continue with adoDB (actually its working fine for me now), then try out SQLRelay, then try SQLAlchemy.

Python in PHP

Well I got php installed in perl, then I tried getting perl in php, but the pecl installer failed. Then I tried python in php - it works!

php shell.php
Python in PHP (2.5.2 (r252:60911, May 28 2008, 08:53:53)
[GCC 4.2.4 (Debian 4.2.4-1)])
>>> 'lowl'
>>> print 'lowl'
lowl
>>>

That is so rad.