Aleksandar • Vacić

iOS bits and pieces

Open source mine

The root of this rant is an epic journey of installing A and P from the LAMP fraternity, for the sole purpose of testing mod_rewrites.

I downloaded Apache 1.3, already had PHP 4.3.9 installed (and running under IIS6), and went to set it all up. To correctly do that, it took me more than 48h full of anger, cursing and despair. This stuff is so bloody complicated and unfriendly that it’s no wonder MS kicks ass each fiscal quarter.

Now, installing Apache may seem like a breeze, but to actually get it working an inch beyond most basic stuff is voodoo. So, I ran the installer, confirmed that web server is on and went to add support for PHP.

There are hundreeds of tutorials on how to do this (I think I read half of them), but most of them tell you to do several steps.

Installing PHP on Apache

Put this line into httpd.conf, at appropriate place:
LoadModule php4_module "c:/php/php4apache.dll"

Little further below, add this line:
AddModule mod_php4.c

Finally, make sure to add this:
AddType application/x-httpd-php .php

Some more detailed tutorials tell you to make sure you put the php4ts.dll in the same directory as php4apache.dll or into windows/system(32) directory. Well, for starters, I did not even had the php4apache.dll. Anywhere. When adding PHP support to IIS6, I took the installer file for Win32. After more reading hours, I learned that I took the incomplete build - there is another, complete, 5x bigger.

Thus, after downloading the .zip, I copied the php4apache.dll where needed, added the line, started the Apache and got:

Cannot load c:/php/sapi/php4apache.dll into server: (127) The specified procedure could not be found.

I’m not even gonna start to list all the things I tried. All the pages I read. All the searches. Despair when I read (on several different forums) that some versions of Apache does not work with some versions of PHP. Hours of waisted time. In the end, it was a case that I needed to copy all the .dll from the dlls directory in the .ziped PHP binaries to windows/system32 and then it finally worked. Maybe some other step too, since I did many things trying to solve the problem. There’s a load of unanswered questions about this error message, all over the web. Hopefully they will find their way here and read this.

Setting up Apache virtual hosts

To create virtual host under Apache that allows .htaccess files to be executed, took me “only” two hours of reading docs, web tutorials and trying things out. Same thing under IIS took me 10 minutes (first time I tried it, now 10s). This is the virtual host setup I use now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<virtualhost *:80>

    ServerAdmin aleck@apache

    DocumentRoot d:devprojectsaplussite-wp1.2

    ServerName apluswp

    ErrorLog logs/aplus-error_log

    CustomLog logs/aplus-access_log common

#    RewriteLog c:rewrite.log

#    RewriteLogLevel 9

    <directory "d:/dev/projects/aplus/site-wp1.2">

    Options All MultiViews

    AllowOverride All

    # or AllowOverride AuthConfig

    Order allow,deny

    Allow from all

    </directory>

</virtualhost>

Directory part is responsible for allowing .htaccess to work. Even though this is done for default Apache host, it is not propagated to virtual hosts. You need to re-enable it, for each one. Logic tells me that when you do something for default host, it should be replicated to all hosts, unless overridden in the virtual host setup. Not here.

Aftewards, I finally got my rewrite.log, and I was able to recreate the rules I had from ISAPI_Rewrite (IIS friendly mod_rewrite implementation). So, 1h for ISAPI_rewrite rules, two hours for rewriting into different syntax that mod_rewrite understands and 2 days in between just to get a working environment. Not a very good use of weekend time.

As my friend often says - there’s no such thing as free lunch. This software is free, but certainly not cheap.