Enabling PCRE JIT in OpenResty on CentOS

I’m quickly finding that openresty is an excellent stack, bundling a large number of nginx modules and Lua functionality. One of the most useful features I’ve found so far is the nginx Lua API’s ability to perform PCRE matches (Lua offers string.find, using a search syntax that is similar to PCRE, but lacks robustness). Performance with PCRE can be increased by using PCRE JIT (just-in-time) compilation; this is required to be present within the underlying system’s PCRE package. JIT was introduce in PCRE 8.21, and, go figure, the upstream package on CentOS is PCRE 7.8.

I had trouble finding a reliable package for PCRE 8 for CentOS, so grabbing the source is the next best option (available from http://www.linuxfromscratch.org/blfs/view/svn/general/pcre.html). Vanilla CentOS installs will need bzip2-devel and readline-devel packages installed. Configuring PCRE with the options provided at the link above (as well as adding –enable-jit) is sufficient; configuring the openresty source without additional options should be enough to enable PCRE JIT within the Lua API (see http://wiki.nginx.org/HttpLuaModule#ngx.re.match for more info on verifying and enabling JIT for given expression matches).

Leave a Reply

Your email address will not be published. Required fields are marked *