Friday, March 23, 2007

Why Free Software Sometimes Hurts

I've been assigned to evaluate a free software, which is a PHP package. I downloaded the package and read through a very brief "readme.first" document. Which indicated that it requires Apache, PHP, and mySQL. Though I never installed PHP before. I thought such combo is a very common and popular combination and I didn't expect too much twist and turn.

First I installed Apache 2.2 for Windows. I had done that thousands times in my life. Then I downloaded and installed PHP5 for Windows. The installer provides automated config for Apache. Pretty!! Finally, I installed mySQL and got it up and running right away.

Everything was ready. I copied the PHP package under the web root and tried to start it. Dada!! Failed. An error message was found in the error log which looks like a program bug in the PHP package. I went through the manual of PHP and asked someone who know PHP better than me. Finally after one day of struggling, I got it working. In fact it could be much simpler. Let see why it took me so long.

1. The PHP5 installer do insert some lines to httpd.conf to load the PHP Apache module, but it forgot an "AddType" statement. I have to add it myself after I found that it is necessary, consulting the installation document.

2. Most PHP programmers use "<? ... ?>" to surround PHP code in the PHP files. While some other PHP tutorial suggest it can also be done like "<?php ... ?>". All files in the PHP package I was evaluating use the pattern "<? ... ?>". However, the default setting of PHP enforce us to use "<?php ... ?>". There is a tiny switch in the config of PHP to enable the use of "<? ... ?>". I need to turn on the switch to make the package work. Hey, why the switch is not turned on by default? Seems to me all PHP programmers prefer the shorter form.

3. Third issue is the connection with mySQL. After more reading of PHP manual, I found that the mySQL connection component is no longer included in PHP5 by default. It turns out that I needed to do 3 things for mySQL connection. First one is I needed to change the "PATH" environment string to let the system found the file "libmysql.dll", which is provided by mySQL. Second is I needed to re-run PHP5 installer to add the mySQL extension for PHP. Finally I modified PHP config for loading the mySQL extension into memory. Why can't they better document these procedures?

Sometimes free software may cost your valuable time in a unexpected way. For some other software which you need to pay, you can call technical support and get your problem solved right away (well, sometimes it may take longer). Luckily I'm never a great fan of PHP.