Previously posted on blog.labrat.info on April 22, 2010

I was trying to install mod_proxy in my Apache install and got into some problems. When trying to use the ports system to recompile Apache with mod_proxy I kept getting the following error.

make reinstall
===>  Installing for apache-2.2.14_5
===>   apache-2.2.14_5 depends on file: /usr/local/bin/perl5.8.9 - found
===>   apache-2.2.14_5 depends on shared library: expat.6 - found
===>   apache-2.2.14_5 depends on shared library: pcre.0 - found
===>   apache-2.2.14_5 depends on shared library: iconv.3 - found
===>   Generating temporary packing list
===>  Checking if www/apache22 already installed
===>   apache-2.2.14_5 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of www/apache22
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /usr/ports/www/apache22.
*** Error code 1

Stop in /usr/ports/www/apache22.
*** Error code 1

Stop in /usr/ports/www/apache22.

Read some articles here and here where the solution was to deinstall and then reinstall. Hell no! My configuration is just how I want it and I’m not going to change everything because the ports systems is very badly broken!

The problem doesn’t seem to happen on compilation but when ports is trying to modify the current install. So the next thing I did was look around in what did get compiled and try to find the modules I wanted.

$ pwd
/usr/ports/www/apache22
$ find . -type f -name '*proxy*.so'
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_connect.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_http.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_ajp.so
./work/httpd-2.2.16/modules/proxy/.libs/mod_proxy_balancer.so

There they are and they look good. So the next thing I did was to copy those over to my current apache install:

$ cp `find . -type f -name '*proxy*.so'` /usr/local/libexec/apache22/

Add the correct module loading bits:

# grep proxy /usr/local/etc/apache22/httpd.conf
LoadModule proxy_module libexec/apache22/mod_proxy.so
LoadModule proxy_http_module libexec/apache22/mod_proxy_http.so
LoadModule proxy_balancer_module libexec/apache22/mod_proxy_balancer.so

And when I restarted apache everything was working just fine. Woo-hoo!