Apache & PHP Setup in Windows

Installing Apache, PHP, MySQL
Install Apache then MySQL with default options. Download and unzip PHP to C:\PHP\ (or other suitable directory).
Apache Config
Edit the httpd.conf file and add the following lines:
LoadModule php5_module C:\php\php5apache2_2.dll
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
(Modify the php dll version according to the PHP version - these files can be seen in the php directory. Pick the one that is most appropriate).
Find the line containing DirectoryIndex, append index.php to the list of default files. E.g:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex index.html index.php
Test Apache
Restart apache from the server monitor.
Navigate to http://localhost/index.html
If Apache is working, a test page should be being displayed.
Test PHP
Create a new file in the docroot, index.php.
Enter the following line:
Navigate to http://localhost/index.php
If PHP is working, a full page of PHP information will be displayed.
PHP Config
From the PHP directory, copy the "php.ini-recommended" file into the windows folder (default: C:\WINDOWS\). Open the INI file and make the following modifications:
- short_open_tag = on
- doc_root = C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ (set to actual apache docroot)
- extension_dir = "c:/php/ext/"
Save and close the php.ini file.
MySQL for PHP
- Uncomment the extension=php_mysql.dll line in the c:\windows\php.ini file.
- Copy the "libmysql.dll" file from the PHP directory into the c:\windows\system32\ directory. (this is one thing that is often forgotten about in other setup guides).
- Restart apache
- Refresh the phpinfo file we created. If the MySQL module is working it will be shown in the list of available modules on the page.
Resetting the MySQL server root password
- Create a new text file "c:\mysql.txt" and place in the text:
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
FLUSH PRIVILEGES;
-
- Stop the MySQL service
- From the command prompt, navigate to the MySQL bin directory
- Run the following command:
- mysqld.exe --init-file=c:\mysql.txt --console