caucho
Resin
FAQ
Reference Guide
Demo
Tutorial

Getting Started
Configuration
IDE
Topics
JSP
XML/XSLT

Resin Web Server
Unix Apache
Windows Apache
Unix Netscape
IIS
WebSite
 Resin with Apache on Windows

Unix Apache
Getting Started
Unix Netscape

Resin provides a fast servlet runner for Apache, allowing Apache to run servlets and JSP files.

  1. Configuring Apache
    1. Alternate Apache Configuration
    2. Dispatching
  2. Load Balancing
  3. Error Page
  4. Configuring resin.conf
  5. Testing the servlet engine
  6. Deploying on NT

Configuring Apache

To configure Apache to load the Caucho Server Runner, add the following lines to the Apache httpd.conf file:

httpd.conf
LoadModule caucho_module <installdir>/resin-2.1.0/libexec/apache-1.3/mod_caucho.dll
# Note, AddModule not needed for Apache 2.0
AddModule mod_caucho.c

<IfModule mod_caucho.c>
  CauchoConfigFile <installdir>/resin-2.1.0/resin.conf
  <Location /caucho-status>
    SetHandler caucho-status
  </Location>
</IfModule>

Note: The caucho-status is optional and probably should be avoided in a production site. It lets you ask the Caucho Apache module about the Caucho status, valuable for debugging.

Alternate Apache Configuration

You can also configure Apache directly, instead of letting mod_caucho read the configuration from the resin.conf file. If you use this method, you need ensure the Apache configuration matches the Resin configuration.

httpd.conf
LoadModule caucho_module <installdir>/resin-2.1.0/libexec/apache-1.3/mod_caucho.dll
AddModule mod_caucho.c

CauchoHost localhost 6802
AddHandler caucho-request jsp
<Location /servlet/*>
   SetHandler caucho-request
</Location>

Apache CommandMeaning
CauchoConfigFile confReads conf for the Resin configuration.
CauchoServerRoot directoryConfigures the equivalent of -server-root.
CauchoHost host portAdds the Resin JVM at host:port as a servlet runner.
CauchoBackup host portAdds the Resin JVM at host:port as a backup servlet runner.

Dispatching

mod_caucho selects URLs specified by the servlet-mapping directives to go to Resin. Other URLs stay with Apache. There's a more complete discussion of the URL dispatching in the plugin-dispatch tutorial.

Load BalancingResin 1.2

In Resin 1.2, you can distribute requests to multiple machines. All requests in a session will go to the same host. In addition, if one host goes down, Resin will send the request to the next available machine.

In addition, you can specify backup machines. The backup only will serve requests if all primaries are down.

See the http config section for more details.

resin.conf
<caucho.com>
<http-server>
  <srun id="a" host='host1' port='6802'/>
  <srun id="b" host='host2' port='6802'/>
  <srun-backup id="c" host='backup port='6802'/>
  ...
</http-server>
</caucho.com>

Error PageResin 1.2

When mod_caucho can't reach any JVM, it will send a default error page. Sites can customize the error page with the error-page directive in the resin.conf.

resin.conf
...
<web-app>
  <error-page exception-type='connection'
              location='/conn_error_page.html'/>
  ...
</web-app>

Configuring resin.conf

By default, Resin will look in resin-2.1.0/doc for JSP files and resin-2.1.0/doc/WEB-INF/classes for servlets and beans. To tell Resin to use Apache's document area, you configure the app-dir. Change app-dir from 'doc' to something like '/usr/local/apache/htdocs'.

resin.conf
<caucho.com>
  <http-server
      app-dir='/usr/local/apache/htdocs'>
    <servlet-mapping url-pattern='/servlets/*'
              servlet-name='invoker'/>

    <servlet-mapping url-pattern='*.xtp'
                        servlet-name='com.caucho.jsp.XtpServlet'/>
    <servlet-mapping url-pattern='*.jsp'
                        servlet-name='com.caucho.jsp.JspServlet'/>
  </http-server>
</caucho.com>

Testing the servlet engine

Now you need to start the servlet engine. From the resin-2.1.0/bin folder, click on srun.

> resin-2.0/bin/httpd

Now browse http://localhost/test.jsp. You should get a 'file not found' message.

Create a test file '/usr/local/apache/htdocs/test.jsp'

2 + 2 = <%= 2 + 2 %>

Browse http://localhost/test.jsp again. You should now get:

2 + 2 = 4

Deploying on NT

The Servlet Runner can be installed as an NT service.

To install the service, use

unix> resin-2.1.0/bin/httpd -install

To remove the service, use

unix> resin-2.1.0/bin/httpd -remove

You will either need to reboot the machine or start the service from the Control Panel/Services panel to start the server. On a machine reboot, NT will automatically start the servlet runner.


Unix Apache
Getting Started
Unix Netscape
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.