Wednesday, April 9, 2008

Configuring PHP on Tomcat

Preparing

PHP Version 5.2.5
Tomcat Version 5.5.25

Let's assume that your current Tomcat install can be found in c:\Tomcat5\

Download PHP and PECL

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

1. Surf to http://www.php.net/downloads.php and download the current version of PHP for Windows machine.
2. Download the corresponding PECL modules.

Configure Tomcat

1. Create a c:\Tomcat5\php\ directory and unzip the PHP zip file in it.
2. Rename php.ini-dist, in c:\Tomcat5\php\, to php.ini
3. Extract php5servlet.dll from the PECL zip file to c:\Tomcat5\php\
4. Create a directory under c:\Tomcat5\webapps\; in our case: phptest
5. In c:\Tomcat5\webapps\phptest\, create a subdirectory: WEB-INF
6. In c:\Tomcat5\webapps\phptest\WEB-INF\,
create web.xml with the following content:



7. Rename php5servlet.dll to php5srvlt.dll.
8. Copy c:\Tomcat5\php\ php5srvlt.dll and c:\Tomcat5\php\php5ts.dll to c:\windows\system32\
9. Create a test page in c:\Tomcat5\webapps\phptest\test.php with this contents:



10. (For Tomcat 4.x copy phpsrvlt.jar c:\Tomcat4\php to c:\Tomcat4\lib)

Run PHP in Tomcat

Start Tomcat and go to http://localhost:8080/phptest/test.php

1 comment: