The Ultimate Apache, PHP and MySQL Windows Installation HowTo - Step By Step Guide - Second Edition

This page has been published by Robert Corsari first time on september 2004 the 26 and upgraded/edited on February 2006 the 27. (Previous Version)
The original page with this info is taken from this post @ Expert Exchange.com


legend (colors meaning): links 
action  variables  variables values  files names  paths


BEFORE YOU STARTAPACHEPHPMySQLTEST FILESTOP


*** BEFORE YOU START DOWNLOADS (watchout versions maybe changed)*** • menu
If a link is broken, set the mouse on it, wait and read instruction  that pops.
download Apache2 :
http://archive.apache.org/dist/httpd/binaries/win32/ • Scroll down and download the last apache_x.x.xx-win32-x86-no_ssl.msi file.
download PHP5 : http://www.php.net/downloads.php • From Windows Binaries section download the last PHP x.x.x zip package.
download MySQL : http://dev.mysql.com/downloads/mysql/5.0.html • From Windows Downloads section download the last "Windows (X86) " file .
download PHP MySQL connector for Windows: http://dev.mysql.com/downloads/connector/php/ • This is a MUST HAVE. Read How to install and FAQs on that page. In few words, you must overwrite PHP installed extensions provided by the PHP installation with those provided by the original My SQL team.
(optionally) download PhpMyAdmin : http://prdownloads.sourceforge.net/phpmyadmin/ • Scroll down and download the last phpMyAdmin-x.x.x.zip file.


*** APACHE Windows Installation - Configuring - HowTO *** • menu
- Install Apache to " <diskDriveLetter>:\<applicationFolder> " using the file apache_2.x.xx-win32-x86-no_ssl.msi
  - DomainName =  default
  - ServerName =  localhost
  - ServerAdmin = webmaster@yourdomain.com
  - ServerPort =  80
- Edit the Apache configuration file " <diskDriveLetter>:\<applicationFolder>\Apache Group\Apache2\conf\httpd.conf" :
  - make sure the value of the port for the "Listen" setting is 80 (and not 8080) :
     Listen 80
  - make sure the value of the port for the "ServerName" setting is 80 (and not 8080) :
     ServerName localhost:80
  - replace the value of the "DocumentRoot" setting to (this mean choose which is the www Folder which will become your published web site) :
     DocumentRoot "<diskDriveLetter>:/<FolderOfYourChoice>/<subFolderOfYourChoice>/www" note that in the httpd.conf file the path must be with / (slash i.e. c:/programs/apache group/apache2/www)
- Test installation :
  - put the attached file index.html in Folder <diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\
     this mean copy index.html "<diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\index.html"
  - start Apache in console (with Apache 2.x.xx, after the installation and the reboot, the server should be already started: restart it with the command in the traybar apache icon)
  - start your favorite Internet browser and go to http://127.0.0.1 :
     the page should say "Available projects on 127.0.0.1 (static) :"


*** PHP Windows Installation - Configuring - HowTO *** • menu
- Extract php-5.x.x-Win32.zip to " <diskDriveLetter>:\<applicationFolder>\php "
- Create a standard PHP configuration file " <diskDriveLetter>:\<applicationFolder>\php\php.ini " :
  to do this, simply
- copy
" <diskDriveLetter>:\<applicationFolder>\php\php.ini-recommended " to a brand new "<diskDriveLetter>:\<applicationFolder>\php\php.ini"

- Edit the PHP configuration file " <diskDriveLetter>:\<applicationFolder>\php\php.ini " :
  - set the extension directory as:
    extension_dir = "./" to "<diskDriveLetter>:\<applicationFolder>\php\ext\" note that here the path must be with \ ( backslash i.e. c:\php\ext\ )
  - uncheck those windows extensions thet you need to be loaded (remove the semicolon ';')
    ;extension=php_gd2.dll
    becomes
    extension=php_gd2.dll (I need this because I use some graphic functions in my php pages)
- Edit the Apache configuration file " <diskDriveLetter>:\<applicationFolder>\Apache Group\Apache2\conf\httpd.conf "  :
  - add the follinwg line after the last LoadModule statement :
     LoadModule php5_module "<diskDriveLetter>:/<applicationFolder>/php/php5apache2.dll" note that in the httpd.conf file the path must be with / ( now with slash i.e. c:/php/php5apache2.dll)
  - add the two follinwg lines after the last AddType statement :
     AddType application/x-httpd-php .php
     PHPIniDir "<diskDriveLetter>:/<applicationFolder>/php"
  - add the value "index.php" to the beginning of the DirectoryIndex list so that the list becomes :
     DirectoryIndex index.php index.html index.html.var
- Test installation :
  - copy the attached file index.php in Folder <diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\
  - copy index.php to "<diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\index.php"
  - start Apache in console (with Apache 2.x.xx, after the installation and rebooting, the server should be already started: restart with the command in the traybar apache icon)
  - start your favorite Internet browser and go to
http://127.0.0.1 :
     the page should say "Available projects on 127.0.0.1 (dynamic) :"


*** MYSQL Windows Installation - Configuring - HowTO *** • menu
- Launch the setup.exe program you find in mysql-x.x.xx-win.zip and start a typical installation in Folder "<diskDriveLetter>:\<applicationFolder>\mysql" (I suggest c:\mysql instead, expecially if you plan to use often the MySQL console and \bin directory)
- Configure the MySQL enviroment. This will be run automatically at the end of setup process. You can also modify the configuration whenever you want navigating to the bin directory of your MySQL installation path and launching the MySQLInstanceConfig.exe file. This procedure will affect the my.ini file which mainly will affect MySQL and the hardware performances.
- Copy (or check if it has been copied to) the libmysql.dll library provided by PHP to your \windows system Folder :
  this mean copy "<diskDriveLetter>:\<applicationFolder>\php\libmysql.dll" to "c:\winnt\system32\libmysql.dll"
- Edit the PHP configuration file "<diskDriveLetter>:\<applicationFolder>\php\php.ini" :
  - change the extension directory :
     extension_dir = from "./" to "<diskDriveLetter>:/<applicationFolder>/php/ext/" if not done before

  - activate mysql by uncommenting (remove semicolon ';' )
     extension=php_mysql.dll

- if you downloaded it, Extract phpMyAdmin-x.x.x.zip to "<diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\phpMyAdminsubFoldername" (one subFolder in the apache www Folder)
  - in that folder edit the file config.default.php to provide it the right MySQL hostname, MySQL user and MySQL password.

- Test installation :
  - reboot your pc/server :
  - copy the attached file test_mysql.php in Folder <diskDriveLetter>:\<FolderOfYourChoice>\<subFolderOfYourChoice>\www\
  - start Apache in console (with Apache 2.x.xx, after the installation and reboot, the server should be already started: restart it with the command in the traybar apache icon)
  - start your favorite Internet browser and open the path http://127.0.0.1/test_mysql.php
  - MySQL testing is possible using this methods instead


- Test phpMyAdmin installation :
  - start your favorite Internet browser and open the path
http://127.0.0.1/phpMyAdminsubFoldername/ . The phpMyAdmin control panel should appear and you should be able to see three databases information_schema, test and mysql. Beware and Keep Off to play with them. Instead choose to create your own one, i.e. mytest.



*** TEST FILES *** • menu

ATTENTION, download doesn't work 'cause my provider won't allow zip and rar download anymore. For this reason you'd better copy and paste each script in the notepad saving it with the suggested name. Only the italic text...

**********
index.html - download
**********
<html><head><title>root</title></head><body>
<center><h3>Available projects on 127.0.0.1 (static) :</h3></center><br><br>
</body>
</html>



**********
index.php - download
**********
<html><head><title>root</title></head><body>
<center><h3>Available projects on 127.0.0.1 (dynamic) :</h3></center><br><br>
<?php
$currentDirectory = dir ( "." );
while ( false !== ( $entry = $currentDirectory->read () ) ) if ( is_dir ( $entry ) && ( $entry != "." ) && ( $entry != ".." ) ) echo "<a href=\"" . $entry . "/\"> " . $entry . "</a><br />\n";
$currentDirectory->close();
?>

**********
test_mysql.php - download - remember to edit username and userpassword with a valid mysql user (maybe the root one for this test)
**********
<html>
<head><title>Test MySQL</title></head>
<body>
<!-- mysql_up.php renamed in test_mysql.php-->
<!-- script courtesy of http://janet.valade.com/ -->
<?php
$host="localhost";
$user="username";
$password="userpassword";

mysql_connect($host,$user,$password);
$sql="show status";
$result = mysql_query($sql);
if ($result == 0)
echo "<b>Error " . mysql_errno() . ": "
. mysql_error() . "</b>";
else
{
?>
<!-- Table that displays the results -->
<table border=”1”>
<tr><td><b>Variable_name</b></td><td><b>Value</b>
</td></tr>
<?php
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo "<TR>";
$row_array = mysql_fetch_row($result);
for ($j = 0; $j < mysql_num_fields($result); $j++)
{
echo "<TD>" . $row_array[$j] . "</td>";
}
echo "</tr>";
}
?>
</table>
<?php } ?>
</body></html>



Kindly offered by FAsTec System Utilities and Freeware Downloads at http://fastec.altervista.org

Counter .