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! π
GREAT!!!! It worked at first try!!!!!
Glad to be helpful! π
Awesome tutorial for noobs like me.
π cheers!
Hi, I was having problems, Google brought me here and your post helped.
Thank you.
This was automatic in php4
glad to help π
yeah, I was also surprised by the change in php5… well, what can you do, just Google! π
Pingback: MySQL is no longer enabled by default - NamePros.com
1) I have below in php.ini
extension_dir = “c:/php5/ext”
extension = php_mysql.dll
2) Copy php.ini to apache’s conf dir which has httpd.conf
3) copy libmysql.dll to the system32 directory
4) restarted apache
though, i still got the below error. Where php.ini should I copy to?
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\order.php on line 14
Thanks so much for ur help!
Lynn
very useful
thank you
You can’t imagine how much unnecessary file transfer you just prevented! π
Thank you so much – I can now freely develop on my local machine instead of a dev server! I had been exploring all sorts of possibilities as to why I was unable to reach a remote MySQL server from my local WAMP setup – Windows firewall blocking outgoing connections, the MySQL server net-blocking my ip, what not!
Phew!
Thank you so much for this post, short sweet and to the point, looked for hours before i found this!
Excellent ! great help. thank you.
great!!! it worked, thank you for your guide!!
thanks, worked like a charm