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):
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.
The Lua/APR binding has an official Debian package which is available in wheezy (testing), sid (unstable) and Ubuntu Oneiric Ocelot (11.10). 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.
The easiest way to download, build & install the Lua/APR binding is to use LuaRocks. 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. How to install these system libraries depends on your choice of operating system and distribution, for example on Debian Linux and derivatives like Ubuntu you can use the following command:
$ apt-get install libapr1 libapr1-dev libaprutil1 libaprutil1-dev \
libaprutil1-dbd-sqlite3 libapreq2 libapreq2-dev lua5.1 \
liblua5.1-0 liblua5.1-0-dev libreadline-dev
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.19.8-1.rockspec
If you have git installed you can also download and install the latest sources directly from GitHub:
$ luarocks install http://peterodding.com/code/lua/apr/downloads/lua-apr-scm-1.rockspec
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.19.8-1.zip
$ unzip lua-apr-0.19.8-1.zip
$ mv lua-apr-0.19.8-1 lua-apr
$ fi
$ cd lua-apr
$ sudo make install_deps # installs build & runtime dependencies for Debian/Ubuntu
$ 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.
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. Please note that the Windows makefile only builds the Lua/APR binding, you need to build APR yourself (see the instructions).
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.
The following functionality has not been implemented yet but is on the to-do list:
If you have questions, bug reports, suggestions, etc. the author can be contacted at peter@peterodding.com. The latest version is available at http://peterodding.com/code/lua/apr/ and http://github.com/xolox/lua-apr.
This software is licensed under the MIT license.
© 2011 Peter Odding (peter@peterodding.com) and zhiguo zhao (zhaozg@gmail.com).