Here is my idiots guid to working with PHP 5, MySql, and Apache on a windows server.
This assumes you have downloaded all of the above mentioned apps and have them installed. If not you can get them here: (
PHP ,
MySQL)
Configure PHP 5 to start talking to MySql.
UPDATE with php 5.2.6 and Apache 2.2 I had to use these instructions –
http://www.php.ph/2008/07/16/windows-installing-php-526-on-apache-229-manually/
- open your php.ini file because you have to add a few entries. (example C:\php\php.ini)
- Once open search for Windows Extensions
- Then add this line “extension=php_mysql.dll ” after it and do not put the ignore “;” in front of it like the others that might already be in the config
- While in the php.ini file search for “extension_dir” and make sure it has a correct path. (example:extension_dir = “c:\php\ext”)
- Double check that mysql is running in your services.
- Restart Apache and check the phpinfo() page to make sure you now have a mysql section before moving on to the next steps.
- Restart apache
- Now setup a test php script page with the following
< ?php // we connect to example.com and port 3306 which is the default
$link = mysql_connect('localhost:3306', 'root', 'password');
if (!$link) { die('Could not connect: ' . mysql_error()); }
echo 'Connected successfully'; mysql_close($link);
Hopefully you get the following response on the page when you view it. “Connected successfully”
Troubleshooting Tips:
- You can use telnet to see if the service is running. start > run > telnet localhost 3306 should give you some sort of response.
- Check (C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf) for the following entries : PHPIniDir “C:/PHP/” and LoadModule php5_module “C:/PHP/php5apache2_2.dll”
This entry was posted in and tagged
MySql,
PHP. Bookmark the
permalink.