Apache Portable Runtime binding for Lua
Lua/APR is a binding of the Apache Portable Runtime (APR) for the Lua programming language. APR powers software such as the Apache webserver and Subversion and Lua/APR makes the APR operating system interfaces available to Lua, serving as an extended standard library. Thus far the following modules have been implemented (the following links take you straight to the relevant documentation):
- Base64 encoding
- Cryptography routines
- Date parsing
- Relational database drivers
- DBM routines
- Environment manipulation
- File path manipulation
- Filename matching
- Directory manipulation
- File I/O handling
- Network I/O handling
- Pipe I/O handling
- Memcached client
- Command argument parsing
- HTTP request parsing
- LDAP connection handling
- Process handling
- Pollset module
- Shared memory
- Signal handling
- String routines
- Multi threading
- Thread queues
- Time routines
- Uniform resource identifier parsing
- User/group identification
- Universally unique identifiers
- Character encoding translation
- XML parsing
How to get and install the binding
You can find the source code of the most recently released version under downloads. The source code is also available online in the GitHub repository. There are Windows binaries available that have been tested with Lua for Windows v5.1.4-40 and there is an offical Debian Linux package. You can also build the Lua/APR binding yourself using the instructions below.
Install using Debian package
The Lua/APR binding has an official Debian package which is available in [wheezy (testing)] wheezy, [sid (unstable)] sid and Ubuntu [Oneiric Ocelot (11.10)] oneiric. If you are running any of those (or a newer release) the following commands should get you started:
$ apt-get install liblua5.1-apr1 $ lua -e "require 'apr.test' ()"
If you are running an older Debian release or a derivative of Debian which doesn't have the official package yet, you may be able to download and install one of the Debian packages manually from one of the three pages linked above.
Build on UNIX using LuaRocks
The easiest way to download, build and install the Lua/APR binding is to use [LuaRocks] lr. The following commands will install the Lua/APR binding from the main repository and run the test suite to make sure everything works:
$ luarocks install lua-apr $ lua -e "require 'apr.test' ()"
If LuaRocks fails to build the Lua/APR binding this is likely because of missing dependencies. Lua/APR depends on the APR, APR-util and libapreq2 system libraries but LuaRocks cannot install these because it only deals with Lua modules. When the build fails the makefile runs a Lua script that knows how to detect missing dependencies on Debian, Ubuntu, Arch Linux, Red Hat, Fedora Core, Suse Linux and CentOS. As a general guideline for other systems and package managers, you'll need the binary and development packages of Lua 5.1, APR, APR-util and libapreq2.
The latest rockspec and sources are also available from the author's website (in case the main LuaRocks repository is unavailable or lagging behind):
$ luarocks install http://peterodding.com/code/lua/apr/downloads/lua-apr-0.23.1-1.rockspec
$ luarocks install http://peterodding.com/code/lua/apr/downloads/lua-apr-scm-1.rockspec
Build on UNIX using makefile
If you don't have LuaRocks installed the following shell commands should help you get started on UNIX:
$ if which git; then # Get the latest sources using `git'? $ git clone git://github.com/xolox/lua-apr.git $ else # Or get the most recently released archive using `wget'. $ wget http://peterodding.com/code/lua/apr/downloads/lua-apr-0.23.1-1.zip $ unzip lua-apr-0.23.1-1.zip $ mv lua-apr-0.23.1-1 lua-apr $ fi $ cd lua-apr $ sudo make install # installs apr.lua and apr/core.so in /usr/local $ lua -e "require 'apr.test' ()" # runs the test suite
The makefile creates a debug build by default. Use
sudo make install DO_RELEASE=1 to create a release build instead. Just be sure to run
make clean when switching between debug/release mode to avoid linking incompatible object files.
Build on Windows using makefile
A makefile for Microsoft Windows is included in the repository. It has been tested on Windows XP with
NMAKE from the free Microsoft Visual C++ Express 2010 tool chain. If you don't have git installed you can download the latest sources directly from GitHub as a ZIP file.
At the top of the makefile several file locations are defined, you'll need to change these to match your system. The makefile creates a debug build by default. Use
NMAKE /f Makefile.win DO_RELEASE=1 to create a release build instead. Just be sure to run
NMAKE /f Makefile.win clean when switching between debug/release mode to avoid linking incompatible object files.
Please note that the Windows makefile only builds the Lua/APR binding, you need to build the APR, APR-util and APREQ libraries yourself. There are instructions available on how to build APR/APR-util on apache.org but my notes on the process may be a more useful starting point.
I've also recently created a Windows batch script that bootstraps a Lua/APR development environment by downloading, unpacking, patching and building the libraries involved. To use it, download the ZIP archive, unpack it to a directory, open a Windows SDK command prompt in the directory where you unpacked the ZIP archive and execute
make.cmd. I've only tested it on a 32 bit Windows XP virtual machine, but even if it doesn't work out of the box for you it may provide a useful starting point.
The following functionality has not been implemented yet but is on the to-do list:
- Encrypted network communication (unfortunately this isn't provided by APR so io_net.c could get messy…)
If you have questions, bug reports, suggestions, etc. the author can be contacted at firstname.lastname@example.org. The latest version is available at http://peterodding.com/code/lua/apr/ and http://github.com/xolox/lua-apr.
The LDAP connection handling module is based on LuaLDAP, designed and implemented by Roberto Ierusalimschy, André Carregal and Tomás Guisasola.
© 2003-2007 The Kepler Project.