It has been a while since I made any updates on my development setup. I figured it’s about time. Doing a quick survey of articles on the best choices (e.g. between Apache 1.XX and Apache 2.XX), I finally made my choices and proceeded to install the following as upgrades:
Apache 2.2.17 to replace Apache 1.6
PHP 5.3.25 to replace PHP 4.3
MySQL 5.5.33 to replace MySQL 3.23
On a machine running Windows XP SP3, you’d think the upgrade would have been simple and straightforward. Considering the old software combo worked well for me for a long time. But no!
Installing Apache was a breeze. The MSI package for PHP gave me a headache. So I eventually downloaded a compressed file and proceeded to manually install it. When I finally got it to work, next came MySQL.
The MSI package download completed successfully. A quick MD5 sum check passed. The installation went well with no error alerts. But when I start it as a service, it just won’t start.
Weeks passed before I finally got another shot at making it work. I needed to start my development server up and running ASAP.
I decided to download a new copy of the installer package. There has been an update from the previous one I downloaded – from 5.5.15, there now was a 5.5.33. Hoping the new one would have probably resolved the problems I have encountered in the previous installation, I set out to download and install it.
The installation goes well, initially. But when the configuration wizard starts to run, it freezes when it gets to starting the service. I kept on attempting to reinstall, about 3 or 4 items i think, but still I ran into the same problem.
Google led me to the Bug posts on the dev pages for oracle/mysql. It appears my case is not isolated and it has been around since 2009. The solution included clearing the registry of all traces of MySQL (especially if you have had old installations) and deleting the old data directory. Apparently, uninstalling MySQL using its uninstall app doesn’t clear out the registry nor does it delete its data directory.
Clearing out the registry was a tedious process as you had to search for the MySQL string and delete them one by one. Sometimes I deleted entire keys, sometimes I deleted just values. The data directory was easy, I found it in “C:\Documents and Settings\All Users\Application data\MySQL”.
After deleting the old data directory and restarting (so the registry changes could take effect), I reinstalled MySQL using the same binary package. A voila! All went well. 😀
The next step was to get the three applications to work together. A little tricky, but attention to detail and patience in reading instructions usually pays off.
Here’s a quick guide on doing this, as extracted from another article:
1. Set PHP path: In My Computer | Properties | Advanced, ensure that
[PHPDIR]
is in thePATH
. If you are installing PHP 4, move all DLLs from both [PHPDIR]\dlls and [PHPDIR]\sapi to [PHPDIR]. For PHP 5, that’s not necessary—the DLLs are already in[PHPDIR]
.2. Configure Apache 2 for PHP: In the text editor window where Httpd.conf is open, look for the section that contains a list of AddType commands, and add this one:
AddType application/x-httpd-php .phpFor PHP 4, in the LoadModule section of Httpd.conf, uncomment or add in:
LoadModule php4_module "c:/php/php4apache2.dll"For PHP 5 it should be:
LoadModule php5_module "c:/php/php5apache2.dll"For PHP 5.2 and later it should be:
LoadModule php5_module "c:/php/php5apache2_2.dll"3. Set up php.ini: Edit a copy of [PHPDIR] \php.ini-recommended as php.ini in your text editor, adjust doc_root andsession.save_path if need be, pick a timezone setting from www.php.net/manual/en/timezones.php, and comment out one extension_dir setting:
doc_root = "c:\apache\htdocs" ; MUST BE THE SAME AS IN Httpd.conf session.save_path = "c:/temp" ; DIRECTORY MUST EXIST date.timezone = "America/Vancouver" extension_dir = "c:\php\extensions" ; FOR PHP 4 ONLY extension_dir = "c:\php\ext" ; FOR PHP 5 ONLYCreate c:\temp if it does not exist. Some PHP manuals have said these path arguments need trailing backslashes, but since PHP 4.3 that is not the case.
4. Apache 2, PHP and MySQL: Up to and including PHP 5.2x: if there is a copy of libmysql.dll in [PHPDIR], copy it to[APACHEDIR]\bin, otherwise copy libmysql.dll from the bin folder of your MySQL installation. For PHP 5.3 and later: remove any copy of libmysql.dll from [APACHEDIR]\bin.
Then ensure that php_mysql.dll and php_mysqli.dll are in
extension_dir
as set in Step 3.Some older Windows installations are missing msvcr71.dll, which PHP may need. If Windows cannot find it in %WINDIR%, Google for it and unpack it into %WINDIR%\system32.
Then in php.ini, uncomment or add:
extension=php_mysql.dll extension=php_mysqli.dllIf you will be using the pdo_mysql interface library (http://forge.mysql.com/wiki/PHP_PDO_MYSQLND), also ensure thatphp_pdo.dll and php_pdo_mysql.dll are in
extension_dir
as set in Step 3, and in php.ini uncomment or add:extension=php_pdo_mysql.dllThe default MySQL host is
localhost
. If MySQL is on another machine on your LAN, set the default MySQL host:mysql.default_host = "networkmysqlservername"Be sure to make these changes to the copies of php.ini in both [PHPDIR] and in [APACHEDIR]\bin!
To see the list of modules you have installed for PHP, from [PHPDIR] issue:
php -m5. CGI mode: If you need to run PHP programs in CGI mode, add to Httpd.conf:
ScriptAlias /php/ "c:/php/" Action application/x-httpd-php"/php/php.exe"6. Test: Save all changes and reboot the machine. To test Apache alone, execute
httpd -k startin
[APACHEDIR]
\bin. If there is an error, Apache will report it immediately in this window. If you prefer, run it from Control Panel | Services | Apache and check[APACHEDIR]\logs\errors
for errors.To ensure that PHP can connect to MySQL via php_mysql.dll, use a text editor to save this code
<?php
mysql_connect('HOST','USR','PWD') or die(mysql_error());
?>substituting your host, username and password values to connect.php in
[PHPDIR]
, open a command window over[PHPDIR]
, and type:
php connect.php
If it fails, redo Steps 1 through 5.
To test Apache’s serving of PHP pages and PHP’s connection to MySQL under Apache, use your text editor to create a simple PHP page, called phptest.php, containing just this line:
<?php phpinfo(); ?>Save to the Apache DocumentRoot folder as phptest.php.
Run it by browsing http://localhost/phptest.php. If everything is working correctly, you will see a page with the PHP logo and a long list of settings. Whether PHP is running through CGI or inside Apache is indicated by the environment variable
script_name
. If PHP is running through CGI, this variable is set to /Php/Php.exe. If Apache is running the PHP script directly, this variable will contain the name of your script, /Phptest.php. In either case, if PHP can connect to MySQL then the page shows a MySQL section. If MySQL and MySQLi sections do not appear on the page, check that the setting labelled Loaded Configuration File in the top section references the php.ini you prepared for this installation.
sources:
http://bugs.mysql.com/bug.php?id=48871
http://www.artfulsoftware.com/php_mysql_win.html
Webmentions
[…] of this one completely blew me away. It was practically faster and less complicated than setting up WAMP on my other machine. I would say I was done in less than half an […]