Install & Configure Apache with PHP, JSP, MySQL, and PHPMyAdmin on Windows 2000/XP
Revision 6
Jeff Lundberg - contact@jefflundberg.com
http://jefflundberg.com/
Introduction:
This is a quick guide to install and configure the Apache web-server with PHP and JSP support on a Windows XP Pro SP2 machine. Let me know if this helps you out! Feedback is appreciated. This is my first “published” guide. I made it for my own reference. Why not share? Did you find this guide useful? I appreciate feedback.
Versions used:
| Windows | XP SP2 |
| Apache | 2.0.52 |
| PHP | 5.0.3 |
| Tomcat | 5.5.4 |
| Java 2 Standard Edition | 5.0 |
| MySQL | 4.1.7 |
| MyODBC Connector/ODBC | 3.51.10 |
| PHPMyAdmin | 2.6.0, patch level 3 |
Change Log:
| 2005.01.09 | Jeff Lundberg |
|
| 2004.12.17 | Jeff Lundberg |
|
2004.12.16 |
|
|
2004.11.24 |
Jeff Lundberg, |
|
2003.08.18 |
Rob Garry |
|
2002.08.01 |
Jeff Lundberg, |
|
2002.07.31 |
|
|
2002.07.26 |
|
Download the Components
Before you can begin, you must first download all the required components. The components used in this tutorial are listed below. You may want to download the latest versions. The versions used in the tutorial have been verified to work.
Apache Web Server
- http://httpd.apache.org/
- http://httpd.apache.or g/dist/httpd/binaries/win32/
- apache_2.0.52-win32-x86-no_ssl.msi
PHP
- http://www.php.net/
- http://www.php.net/downloads.php
- php-5.0.3-Win32.zip
JSP
- Tomcat ( http://jakarta.apache.org/site/binindex.cgi)
- jakarta-tomcat-5.5.4.exe
- JK2 Connector
- http://apache.mirrors.esat.net/jakarta/tomcat-connectors/jk2/binaries/win32/
- jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip
- Java
- Download the latest Java Runtime.
- http://java.sun.com/
- http://java.sun.com/j2se/1.5.0/download.jsp
- Click Download JRE
- Accept & click Continue
- Under “Windows Platform”, choose the “Windows Offline Installation”
- jre-1_5_0-windows-i586.exe
MySQL
- MySQL Database
- http://dev.mysql.com/downloads/mysql/
- Download the latest stable release for Windows
- mysql-4.1.7-win.zip
- MyODBC
- http://www.mysql.com/downloads/
- Download the latest stable release of Connector/ODBC for Windows
- MyODBC-3.51.10-x86-win-32bit.msi
- PHPMyAdmin
- http://www.phpmyadmin.net/
- Download the latest stable release of PHPMyAdmin (.php files)
- phpMyAdmin-2.6.0-pl3.zip
Note to Windows 2000 users:
This guide should work with Windows 2000 as well. Remember to replace C:\WINDOWS with C:\WINNT anywhere in this document.
Apache
- Run apache_2.0.52-win32-x86-no_ssl.msi



- Fill in the information and choose “for All Users, on Port 80, as a Service -- Recommended” when prompted.





- Finish the installation program.

- If you have Windows Firewall enabled, select Unblock on the Windows Security Alert. Zone Alarm will also popup a message. For any firewall, make sure port 80 is open.

- Test: Open http://localhost in a web browser. If you see something like that following, you’ve just successfully installed Apache!

PHP
- Extract php-5.0.3-Win32.zip into C:\php

- Copy and rename c:\php\php.ini-recommended to c:\php\php.ini
Note: Before, we used to copy php.ini to the C:\WINDOWS directory. This is not required with the Apache “PHPIniDir” directive pointing to c:\php.
- Open php.ini and change the following and then save it.
include_path = ".;C:\php\includes\"
session.save_path = "C:\Temp"
session.cookie_path = \
doc_root = "C:\Program Files\Apache Group\Apache2\htdocs"
extension_dir = "C:\php\ext\"
extension=php_mysql.dll
extension=php_mysqli.dll
mysql.default_port = 3306
mysql.default_host = localhost
mysql.default_user = root
mysqli.default_port = 3306
mysqli.default_host = localhost
mysqli.default_user = root -
Add C:\php to your PATH System Environment Variable.
- Right-click on My Computer and choose Properties.
- Select the Advanced tab.
- Click Environment Variables.
- Under System variables, select “Path” and choose Edit.
- Move the cursor to the end of the string and add ;C:\php.
- A basic path will look something like the following
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\php
- A basic path will look something like the following
- Add the following lines to httpd.conf:
Note: httpd.conf is located in C:\Program Files\Apache Group\Apache2\conf\
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
- Change the following line in the httpd.conf.
Note: If you don’t plan on adding JSP support, don’t add index.jsp.
From:
DirectoryIndex index.html index.html.varTo:
DirectoryIndex index.php index.jsp index.html index.html.var - Test: Restart Apache & open http://localhost in a web browser. Hopefully you see the same thing as before.
Hint: To quickly restart Apache, simply left-click (once) on the Apache system tray icon.


- Test: Create a new text file called phpinfo.php. Paste the following into it.
Save the document under C:\Program Files\Apache Group\Apache2\htdocs. Now open http://localhost/phpinfo.php in a web browser. You should see something like the following:<?php phpinfo();?>

- Test: To check if the modules are loading correctly, scroll down. If the modules are working, you should see a section for “mysql” and “mysqli”.
Note: If you don’t want to add C:\php to your path, you may copy libmysql.dll to your C:\Windows\System directory.
JSP
- Run jre-1_5_0-windows-i586.exe




- Run jakarta-tomcat-5.5.4.exe.


- Select service to have Tomcat automatically startup when Windows starts.
Note: If you want to run some tests later, install the Examples as well. The examples allow you to test everything to make sure it’s all working properly.


- Type in some admin password you can remember. Leave it on port 8080.



- Click Finish.

- Test: Start Tomcat. If you chose Run Apache Tomcat on the previous screen, it will start automatically.

You should see two icons in your system tray at this time.
Open http://localhost:8080/ in a web browser. You should see something like the following:

- Extract mod_jk2.so from jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip to
C:\Program Files\Apache Group\Apache2\modules.
- Add the following to the "Load Modules" section of your Apache http.conf file
LoadModule jk2_module modules/mod_jk2.so
- Create a new text document called workers2.properties. Save this document in the following directory:
C:\Program Files\Apache Group\Apache2\conf. Put this text into the file:
[shm]
file=C:\Program Files\Apache Group\Apache2\logs\jk2.shm
size=1048576[channel.socket:localhost:8009]
port=8009
host=127.0.0.1[ajp13:localhost:8009]
channel=channel.socket:localhost:8009[status:status]
[uri:/jsp-examples/*]
worker=ajp13:localhost:8009[uri:/status/*]
worker=status:status - Add the following to the end of the jk2.properties file located in
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\
Note: Always start Tomcat first and then start Apache. If you have to bounce Tomcat, remember to take down Apache first and restart it after Tomcat restarts.handler.list=channelSocket,request
channelSocket.port=8009
channelSocket.address=127.0.0.1
- Test: Begin by shutting down both Apache and Tomcat. Start the Tomcat service. Open http://localhost:8080/ in a web browser. You should see something like the following:

If you installed the examples, test out the JSP Examples as well as the Servlet Examples to make sure they work. If they do not work, something is wrong with your Tomcat installation. (It’s much easier to stop the Tomcat service, uninstall it, and start over again. Troubleshooting this is not fun as there’s little documentation available.)
- Test: Start up the Apache2 service and open http://localhost/ in a web browser. Still working?
- Test: Now try http://localhost/phpinfo.php to make sure that’s still in working order.
- Final Test: Open http://localhost/jsp-examples/ in a browser, you should see something like the following:
MySQL
- Run setup.exe from mysql-4.1.7-win.zip.









- Enter a root password, confirm it, and then click Next >.



- Test: Open a command prompt and navigate to C:\Program Files\MySQL\MySQL Server 4.1\bin\ Type in the command
mysqlshow -u root -p
Enter the password you supplied earlier. It should display the current databases.

MyODBC
- Run MyODBC-3.51.06.exe.
Note: Installing MyODBC is optional.





- Click Finish.

PHPMyAdmin
- Extract phpMyAdmin-2.6.0-pl3.zip to your htdocs directory and rename it to something like “phpmyadmin” (e.g. C:\Program Files\Apache Group\Apache2\htdocs\phpmyadmin).
Note: You may want to use a .htaccess file or use the following to prevent random people from accessing PHPMyAdmin.
- Open the config.inc.php (in the phpmyadmin directory) in your favorite text editor and modify the following variables:
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin/';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'http';
- Open http://localhost/phpmyadmin/ and login using “root” (password is whatever you set it to earlier).

Congratulations!!!
Resources
Apache
PHP
Perl
http://www.perl.com/
http://www.activestate.com/
JSP
http://www.acg-gmbh.de/mod_jk/
http://www.galatea.com/flashguides/apache-tomcat-24-win32.xml
http://www.jguru.com/faq/view.jsp?EID=853905
MySQL
http://www.mysql.com/
http://www.phpmyadmin.net/
Other
http://www.experts-exchange.com/
Special Thanks!
Special thanks to Andrew Conrad, Rick Reumann, Dallas Thunder, Andrei Isakov, and Mark Gearhart for their helpful feedback.