Wednesday, March 12, 2008

getting up and running with WAMP

WAMP: Windows XP, Apache Tomcat 6, MySQL and PHP.

Having been done this many times on Linux, I decided to setup my laptop with all these tech-essentials.

The first step was to get these running indipendently and then making sure that they run together.

1) Tomcat 6
This was probably the easiet to get up and running.
1.1 --> Just unzip/untar the package under D:\ say as tomcat6.
1.2 --> Go to D:\tomcat6\bin and execute startup.bat
1.3 --> Change the port number in D:\tomcat6\conf\server.xml, if you want to.

2) MySQL
I decided to go with no-install executable so I can start and stop the server wheneven I want.
2.1 --> It was unzipped under D:\mysql
2.2 --> You can put the following directory under the PATH
D:\mysql\bin
2.3 --> start the server as "mysqld --verbose"
2.4 --> shutdown the server using "mysqladmin -u root shutdown"
2.5 --> you can test the connection using mysql -u root
play away.

3) PHP with Tomcat
3.1--> Download the zip package or installer from Windows Binaries section of this url
http://us3.php.net/downloads.php
3.2 --> Download the pecl Win32 binaries from the above page
3.3 --> Unzip php to D:\php
3.4 --> Unzip pecl to D:\pecl
3.5 --> copy D:\php\php.ini-dist to D:\php\php.ini
3.6 --> In php.ini, uncomment the following line by removing the ";" (semi colon) or if the line doesn't exist, please add it
;extension=php_java.dll
3.7 --> Copy the php5servlet.dll from D:\pecl to D:\php
3.8 --> Create the following directory path in tomcat
D:\tomcat6\webapps\php\WEB-INF\lib
3.9 -->Create a file
D:\tomcat6\webapps\php\WEB-INF\web.xml
with the following content




<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>php</servlet-name>
<servlet-class>net.php.servlet</servlet-class>
</servlet>
<servlet>
<servlet-name>php-formatter</servlet-name>
<servlet-class>net.php.formatter</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>php</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>php-formatter</servlet-name>
<url-pattern>*.phps</url-pattern>
</servlet-mapping>
</web-app>



3.10 --> Unjar the phpsrvlt.jar from the D:\pecl directory. If you un-jar is under D:\, one of the path would look like
D:\net\php
The two files under this directory will be reflect.properties and servlet.properties.
3.11 --> make sure the line in the above properties files looks like
library=php5servlet
this needs to be same as the dll which you copied in step 3.7
3.12 --> If you changed the above files to correct the library parameter, then re-create the jar file using the command below from D:\
jar cvf php5srvlt.jar net/php/*.*
3.13--> copy the jar file to
D:\tomcat6\webapps\php\WEB-INF\lib
3.14 --> Add PHP to your System or User PATH variable.
3.15 --> Create a test file called
D:\tomcat6\webapps\php\test.php
with the following content

3.16 --> start your tomcat server and test the PHP installation by going to
http://localhost:8080/php/test.php

If everything is working fine, then you'll see lot of php details on the webpage


4) PHP with Tomcat and MySQL
4.1 --> Unzip the following lines from D:\php\php.ini, or add them if they do not exist
;extension=php_mysql.dll

;extension=php_mysqli.dll
4.2 --> Copy the following files from D:\php\ext to D:\php
php_mysql.dll

php_mysqli.dll
Or you can also change the following property in php.ini
extension_dir = "d:\php\ext"
and move all the dll's to D:\php\ext
4.3 --> Test the php integration with mysql under tomcat. Make sure to restart the webserver.
4.4 --> If it still doesn't work, sometime you need to copy the above DLL's to C:\windows\system32 directory.

Good luck.

No comments: