If you are like a lot of people with a Ubuntu 12.04 server you will have upgraded to apache 2.4 and/or php 5.5.x buy adding a PPA like this one. One caveat with this raises it’s head when you want to compile apache modules.

To compile apache modules you need to use apxs or apxs2 (APache eXtenSion tool) which is provided by the apache2-dev package. Now since your running apache 2.4 you cant use the one that comes from the precise repo and there is usually not one on the PPA you used to upgrade Apache/PHP.

You can however manually download the appropriate package for your server from somewhere like http://packages.ubuntu.com/wily/apache2-dev.

Install apache-dev dependencies 1st
# sudo apt-get install libapr1-dev libaprutil1-dev

Download the package
# wget http://mirrors.kernel.org/ubuntu/pool/main/a/apache2/apache2-dev_2.4.12-2ubuntu1_amd64.deb

Install the package
# sudo dpkg -i apache2-dev_2.4.12-2ubuntu1_amd64.deb

The next problem you’ll potentially face is that your upgraded version of apache build tools is trying to use some new features of the g++ compiler that were added in version 4.9.  You could try an update your version of G++ but this is more difficult than you would think on 12.04.

In my case I just needed to get this module built and installed ASAP (mod_cloudflare). When running the build command it would thrown the following error:

# apxs2 -a -i -c mod_cloudflare.c
/usr/share/apr-1.0/build/libtool –silent –mode=compile –tag=disable-static x86_64-linux-gnu-gcc -std=gnu99 -prefer-pic -pipe -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -c -o mod_cloudflare.lo mod_cloudflare.c && touch mod_cloudflare.slo
cc1: error: unrecognized command line option ‘-fstack-protector-strong’
apxs:Error: Command failed with rc=65536

The -fstack-protector-strong option on the compile is the option that has not been added to the version of g++ that you have installed.

Change directories to the Apache build directory
# cd /usr/share/apache2/build/

Backup the files using this option
# sudo cp config.nice config.nice.orig
# sudo cp config_vars.mk config_vars.mk.orig

Edit and change all occurrences of -fstack-protector-strong to -fstack-protector
# sudo vi config.nice (2 places)
# sudo vi config_vars.mk

Now you will be able to build the module!

 

 

 

 

 

 

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>