January 31, 2010

Compiling Apache 2.0 to support mod_rewrite

For a recent project, I downloaded the Apache 2.2.14 Unix source (http://apache.mirrors.tds.net/httpd) to assist in our automated BPEL/ANT compilations.

We added the following rewrite rules:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^wsdl$
RewriteRule ^(.*)$ $1.wsdl [PT]
But when we started Apache, we received the following error:
oracle@oradev:/u01/httpd-2.2.14/bin> ./apachectl start

Syntax error on line 411 of /u01/httpd-2.2.14/conf/httpd.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
This is because when Apache was compiled using make, we forgot to include the appropriate flag.

This is the correct way to compile Apache to include the mod_rewrite module:

cd /u01
gtar -xzvf httpd-2.2.14.tar.gz
cd httpd-2.2.14
./configure --prefix=${PWD} --enable-rewrite=shared
make install
Afterwards, you will notice the mod_rewrite module being automatically configured to load in httpd.conf.

Now adding your rewrite rules will work.

1 comment:

  1. This is a very good site article material and it is very useful for us all. Thank you. . obat menggugurkan kandungan