Apache+mySQL+PHP is for sure among the best and the most popular combinations of web-development products; but sometimes a proper setup is a tricky bit.
Among the things that need a lot of messing around is how to enable mySQL under PHP5. While mySQL is in PHP4 implicitly(?) enabled, under PHP5 you have to do all this:
After installing Apache 2.0/2.2, PHP5, and mySQL (e.g. by installing XAMPP), copy php5apache2.dll or php5apache2_2.dll (depending on your Apache version) to modules directory of Apache.
Then, add the following 2 lines to httpd.conf (typically in <Apache_dir>/ conf/ httpd.conf):
LoadModule php5_module modules/php5apache2[_2].dll AddType application/x-httpd-php .php
This will enable PHP5 to work properly in Apache 2.
To enable mySQL for use in PHP5, you have to do the following:
- [not sure if this is really necessary --] Make sure you have valid php.ini file in <Apache_dir>.
- Copy libmysql.dll to the system32 directory (in Windows installation directory). (php_mysql.dll won’t load without doing this!)
- Set the extension_dir in php.ini to the ext directory of your PHP installation directory – typically “extension_dir = <PHP_installation_dir>\ ext”.
- Enable the mySQL extension in php.ini by un-commenting the line “extension = php_mysql.dll”.
- Restart Apache Server.
That’s all… enjoy!