July 19, 2007, at 11:58 PM
Tips /

RecompilingApacheOVH

A sys admin tip ... gloups.

Context

Today (20070719) I wanted to run a CherryPy application (and server) behind Apache. Because ... my understanding is that in my situation it is the best thing to do :P

I struggled for a long time until I realized that what it came down to is recompiling Apache with mod_proxy enabled. The trick with OVH is that, if you want them to do the security patches job for you (still need to apply them yourself), you can't really customize your apps that much without having to redo it every time you run patch that has an impact on the bloody setup.

I decided to go ahead with it anyway. I think it will be more elegant that combining mod_rewrite and the CherryPy proxy tool as suggested in CPE.

How to

On a pre-installed server by OVH, most sources are kept in the /home/ovh/src/ folder. Today on my box I run Apache 1.3.37 so the action takes place in ...

[root@ns33467 root]# cd /home/ovh/src/apache_1.3.37

The default ovh configuration is specified in the config.status file.

[root@ns33467 apache_1.3.37]# cat config.status
#!/bin/sh
##
##  config.status -- APACI auto-generated configuration restore script
##
##  Use this shell script to re-run the APACI configure script for
##  restoring your configuration. Additional parameters can be supplied.
##

./configure \
"--with-layout=Apache" \
"--prefix=/usr/local/apache" \
"--activate-module=src/modules/php4/libphp4.a" \
"--enable-suexec" \
"--suexec-caller=nobody" \
"--suexec-userdir=www" \
"--suexec-docroot=/home" \
"--suexec-logfile=/usr/local/apache/logs/cgi.log" \
"--suexec-uidmin=99" \
"--suexec-gidmin=99" \
"--suexec-safepath=/usr/local/bin:/usr/bin:/bin" \
"--enable-module=so" \
"--enable-module=rewrite" \
"--add-module=src/modules/extra/mod_gzip.c" \
"--enable-module=ssl" \
"$@"

To enable mod_proxy at compile time you need to use the --enable-module=proxy flag when configuring then ...

[root@ns33467 apache_1.3.37]# ./config.status --enable-module=proxy
...
[root@ns33467 apache_1.3.37]# make
...
[root@ns33467 apache_1.3.37]# make install

Note that the config.status file is updated to reflect the fact that the flag was used to build the server.

To check that mod_proxy is enabled one can do:

[root@ns33467 apache_1.3.37]# /usr/local/apache/bin/httpd -l
Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_status.c
  mod_include.c
  mod_autoindex.c
  mod_dir.c
  mod_cgi.c
  mod_asis.c
  mod_imap.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_rewrite.c
  mod_access.c
  mod_auth.c
  mod_proxy.c
  mod_so.c
  mod_setenvif.c
  mod_ssl.c
  mod_php4.c
  mod_gzip.c
suexec: enabled; valid wrapper /usr/local/apache/bin/suexec

Hopefully this or something similar will work :P