Apache and Apache Tomcat Tony Collings, February 2007



Download 24.7 Kb.
Date29.07.2017
Size24.7 Kb.
Apache and Apache Tomcat

Tony Collings, February 2007


Summary

OK, first things first Apache is NOT Apache Tomcat. They are two separate products. Whilst both products fall under the Apache “umbrella”, and their internal workings are very similar they are, in fact, different products.




  • Apache HTTP Server
    (Versions 2.0 – 2.2 )
    http://httpd.apache.org/docs/2.2/ and




  • Apache Tomcat
    (Versions 3.3 – 6.x )
    http://tomcat.apache.org/tomcat-6.0-doc/index.html

Web applications for Tomcat are stored in $CATALINA_HOME\webapps and conversely

Web applications for Apache are stored in $CATALINA_HOME \htdocs
Tomcat often refers to $CATALINA_HOME, which simply translates to the home directory in which Tomcat was installed.
Unlike IIS, Apache HTTP Server doesn’t really come with a nice looking GUI front end, instead most configuration is done in config files.
For Apache this is : \conf\httpd.conf

And for Tomcat this is : \conf\server.xml


However Apache Tomcat comes with some GUI web based front ends.

These are located under

$CATALINA_HOME\server\webapps\admin and

$CATALINA_HOME\server\webapps\manager respectively


To access them simply use the respective URL’s

$DOMAIN_NAME:8080/admin

$DOMAIN_NAME:8080/manager
Notes

The commands make, configure and cp often mentioned in GNU Open Source software refer to UNIX commands and as such are obviously not available to a Win32 OS

Apache Tomcat
Users

Users are defined in $CATALINA_HOME/conf/tomcat-users.xml


This is broken down into roles and user in those roles. A similar concept to Users and Groups
Typically a web.xml will define these values.


admin




The role that is required to log in to the Administration Application

admin


These are associated with the tomcat-users.xml file.


Web Configuration Files

Apache Tomcat also uses a web.xml in addition to server.xml. Web.xml configures specifics for each WEBAPP, defining parameters in $CATALINA_HOME\conf\web.xml cascades to ALL web applications. Individual applications can have their own web.xml located in $CATALINA_HOME \WEBAPPS\$APP_NAME\WEB-INF\web.xml. These will override the default web.xml settings.


Adding New Web Applications

Unlike Apache, Tomcat requires that you “install” your application. To do this you need to access the Tomcat Web Application Manager, and under the “install” section enter the url of your webapp and hit install.

Adding the following to your $WEB_APP\WEB-INF\web.xml will add something a bit more descriptive in the Tomcat Application Manager


Tony's Test Application

Tony's Test Application







To enable PHP in Tomcat

Tomcat is primarily a (Java) Servlet engine, and because of this php doesn’t run natively. So you need to down load a servlet and configure it to handle php requests.




  1. Download latest php
    http://www.php.net

  2. Download latest collection of PECL modules
    http://www.php.net

  3. Unzip php 5.x zip file anywhere, normally c:\php

  4. Copy php.ini-dist, in c:\php, as php.ini

  5. Uncomment the line (remove semi-colon at the beginning) in php.ini:
    ;extension=php_java.dll

  6. Extract php5servlet.dll from pecl zip file to c:\php (Uncheck "Use Folder Names" in WinZip).
    Ensure that the file is actually present in c:\php

  7. Install Tomcat and create a directory under webapps. Lets say it is named fun.

  8. Create WEB-INF directory under fun

  9. Create lib directory under WEB-INF

  10. Create web.xml under WEB-INF with the following contents:

    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">


    php
    net.php.servlet


    php-formatter
    net.php.formatter


    php
    *.php



    php-formatter
    *.phps





  1. Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\

  2. Modify both the files in c:\net\php\reflect.properties and servlet.properties to change the line library=phpsrvlt to library=php5servlet and save them. This indicates the file name of the dll file which is loaded by the Java application to serve the requests. In my version the name of the dll was php5servlet.dll. Your mileage may vary. This has no connection with the name of the jar file which can be anything.

  3. Re-create the jar file

  4. Copy the jar file to WEB-INF\lib directory created earlier

  5. Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer)

  6. Create a file test.php under fun with the following code:



  1. Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat).

  2. Open your browser and go to http://localhost:8080/fun/test.php

  3. Ensure that there are no errors displayed. Instead you get an informative screen with php version information and whole lot of details

Another article detailing a method to get PHP running on Tomcat is located here :
http://wiki.apache.org/tomcat/UsingPhp
Libraries

Tomcat works on various Java libraries (.jar). These can be located globally under $CATALINA_HOME \common\lib\ or locally under $CATALINA_HOME \WEBAPPS\$APP_NAME\WEB-INF\lib\

Apache HTTP Server
To enable PHP in Apache
Firstly locate the httpd.conf file in $CATALINA_HOME\conf
Then simply add
# Added for php support

LoadModule php5_module "c:/php/php5apache2.dll"

AddType application/x-httpd-php .php

PHPIniDir "C:/php"


To your .conf file.

Download 24.7 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2020
send message

    Main page