Tuesday, August 01, 2006

Install PHP5 with Apache2 and mysql on windows

Today I installed php5 on my working desktop to edit my baby's website: www.qqvivian.com.
Here is my experience:
Windows + Apache 2 + PHP 5 installation (This only applies to Apache 2.0.x, for 2.2.x, the dll doesn't work)

1. Install Apache.
2. Unzip PHP to a directory, add it to path and PHP_HOME
3. Copy php\php.ini-recommended to windows\php.ini
4. Edit php.ini, set doc_root to apache htdocs directory
5. Edit php.ini, set extension_dir, uncomment extension=php_bz2.dll.
6. Install php as Apache module: Add the following lines to "httpd.conf" file under apache conf directory.
LoadModule php5_module "php/php5apache2.dll"
AddType application/x-httpd-php .php
7. Add test page phpinfo.php, restart Apache to see.

Everything is easy, except one tricky point. The above steps work only for Apache version 2.0.x, it will not work for latest 2.2.x. Obviously the php dll files are not fresh for 2.2.x.

After that, I try to configure php working with existing mysql database:
Still everything is clear, two steps involved: uncomment php_mysql.dll ext in php.ini and expose "libmysql.dll" file in "path". However this will not work, I am getting the error of: "PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0"

After google for a while I found an excellent solution:


You have to copy "libmysql.dll" file to "windows\system32" directory. Yes, I know, it is already in the Path, you still have to do it. I believe it is related to windows security issue set by MS. Seems this is a very common problem, but the answer is not so obvious from php or mysql website. I update a wiki to post the solution:


No comments: