Compiling mod_jk on apache 2.4

Sorry for brazilian users that cant read it, but at this time, i will post in english, because this can help everyone to solve this problem.

Im was trying to compile mod_jk on the lastest version of apache (2.4) and get this error on “make”

Making all in apache-2.0
make[1]: Entering directory `/usr/local/install/Java-packages/tomcat-connectors-1.2.32-src/native/apache-2.0′
/usr/local/apache2/build/libtool –silent –mode=compile gcc -std=gnu99 -I/usr/local/apache2/include  -DHAVE_CONFIG_H -DUSE_APACHE_MD5 -I ../common -I /usr/java/j2sdk//include -I /usr/java/j2sdk//include/unix -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -DHAVE_APR  -I/usr/local/apache2/include -I/usr/local/apache2/include  -DHAVE_CONFIG_H -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -c mod_jk.c -o mod_jk.lo
mod_jk.c: In function ‘init_ws_service’:
mod_jk.c:767: error: ‘conn_rec’ has no member named ‘remote_ip’
mod_jk.c:768: error: ‘conn_rec’ has no member named ‘remote_addr’
mod_jk.c:1036: error: ‘conn_rec’ has no member named ‘remote_ip’
mod_jk.c:1036: error: ‘conn_rec’ has no member named ‘remote_ip’
make[1]: *** [mod_jk.lo] Error 1

Reading the API documentation i found the solution.

the file apache-2.0/mod_jk.c uses conn_rec->remote_ip and conn_rec->remote_addr that was discontinued on the new API

For a perfect compilation, edit apache-2.0/mod_jk.c file and change the lines below:

Line 767:

Before:
s->remote_addr = r->connection->remote_ip;
After (with patch):
s->remote_addr = r->connection->client_ip;

Line 768:

Before:
s->remote_port = apr_itoa(r->pool, r->connection->remote_addr->port);
After:
s->remote_port = apr_itoa(r->pool, r->connection->client_addr->port);

Line 1036:

Before:
STRNULL_FOR_NULL(r->connection->remote_ip),
After:
STRNULL_FOR_NULL(r->connection->client_ip),

Now, the “make” command can run perfect! 😉

Usando vários núcleos no make

Dica do Cifali

make -j17

aonde 17 é a quantidade de núcleos+1 que deseja usar na compilação. nesse caso usamos 16 nucleos, ou seja, se a maquian que  for compilar tiver 4 núcleos, usar -j5

OBS: Na documentação do make não recomendam usar essa opção, mas até agora não tivemos problemas neste quesito.
OBS2: Isso aumenta consideravelmente o load do servidor, então cuidado!