<title css='default.css'>Resin Web Server on Unix or Windows</title>

<summarylist/>

<p/>Resin provides a standalone web server.  In our benchmarks, it actually
serves static pages faster than Apache!  The standalone web server
is ideal for evaluation or experimentation and is a good choice as the
web server for many sites.

<center>
<ct:img src='httpd.gif'/>
</center>

<section title='Testing and Evaluation'>

To start the Resin web server, type:

<example title='Starting on Unix'>
unix> resin-2.0.x/bin/httpd.sh
Resin 2.0.s010831 (built Fri Aug 31 21:36:18 PDT 2001)
Copyright(c) 1998-2001 Caucho Technology.  All rights reserved.

Starting Resin on Mon, 03 Sep 2001 19:15:22 -0700 (PDT)
http listening to *:8080
srun listening to localhost:6802
</example>

<example title='Starting on Win32'>
c:\win32> resin1.2\bin\httpd
Resin 2.0.s010831 (built Fri Aug 31 21:36:18 PDT 2001)
Copyright(c) 1998-2001 Caucho Technology.  All rights reserved.

Starting Resin on Mon, 03 Sep 2001 19:15:22 -0700 (PDT)
http listening to *:8080
srun listening to localhost:6802
</example>

<p/>Resin will print every port its listening to.  In the above example,
Resin is listening to port 8080 using HTTP and 6802 using its servlet
runner protocol.  (The servlet runner protocol only matters if you're
using Resin with another web server, like Apache.)

<p/>The following snippet shows the <var/&lt;http>/> and <var/&lt;srun>/>
configuration for the above example.

<example>
&lt;caucho.com>
  &lt;http-server>
    &lt;http port='8080'/>
    &lt;srun host='localhost' port='6802'/>

    ...
  &lt;/http-server>
&lt;/caucho.com>
</example>

The default port is 8080, so use http://localhost:8080 in your browser.

<p/>Go to the demos and make sure they work.

<p/>Now, add a file resin-2.0.x/doc/test.jsp containing the following:
<example>
2 + 2 = &lt;%= 2 + 2 %>
</example>

You should see the page '2 + 2 = 4'.

</section>

<section name='deploy' title='Deploying on Unix'>

A better way to run the servlet engine in a production environment is
to use the start and stop scripts.  These run Resin as a unix daemon
and add extra reliability to the server.  If Resin should ever exit,
it will automatically be restarted.  When developing, however, running Resin
in the foreground is often more convenient.

<p/>To start the web server, use

<example>
unix> resin-2.0.x/bin/httpd.sh start
</example>

<p/>To stop it, use

<example>
unix> resin-2.0.x/bin/httpd.sh stop
</example>

<subsection title="wrapper.pl">

Resin uses a perl script, resin-2.0.x/bin/wrapper.pl, to control the Java
process.  (bin/httpd.sh is a tiny shell script that calls wrapper.pl.)  You
can modify bin/httpd.sh or bin/wrapper.pl for your configuration.

<p/>wrapper.pl automatically restarts Resin when it determines the Java process
has died.  If you need to stop Resin with <var/kill/>, you'll need to kill
the wrapper.pl process to make sure it doesn't restart Resin.  ("httpd.sh stop"
works by killing the wrapper.pl process.)

</subsection>

<subsection title="Starting as a user">

Many configurations launch Resin from the init as another user.  Here's an
example:

<example>
root# su ferg -c "/home/resin/start"
</example>

The start script might look like:

<example>
#!/bin/sh

JAVA_HOME=/usr/java
RESIN_HOME=/home/resin

export JAVA_HOME
export RESIN_HOME

cd $RESIN_HOME

bin/httpd.sh -verbose start
</example>

</subsection>

</section>

<section title="The bin/resin program">

On some Unixes, the ./configure; make process will build a bin/resin
executable.  You can use that executable to launch Resin, just like
using httpd.sh:

<example>
unix> resin-2.0.x/bin/resin -conf conf/test.conf start
</example>

<p/>The bin/resin executable will let you run Resin standalone as another
user than root.  To use the user-name and group-name directives, you
must use bin/resin.

</section>

<section title='Deploying as an NT Service'>

The Resin Web Server can be installed as an NT service.

<p/>To install the service, use

<example>
c:\> resin-2.0.x\bin\httpd -install -conf/myconf.conf
</example>

<p/>To remove the service, use

<example>
c:\> resin-2.0.x\bin\httpd -remove
</example>

<p/>You will either need to reboot the machine or start the service
from the Control&nbsp;Panel/Services panel to start the server.  On a
machine reboot, NT will automatically start the web server.

<p/>You can also start and stop the service from the command-line:

<example>
c:\> net start resin
...
c:\> net stop resin
</example>

<p/>Resin's -install saves the command-line arguments and starts the service
with those arguments.  You can look at them in the control panel, under
the executable string.

<p/>With multiple servers, you can use -install-as <var/foo/> to specify
the service name.

<example>
c:\> resin-2.0.x\bin\httpd -install-as ResinA -conf/myconf.conf -server a
c:\> net start ResinA
</example>

</section>

<section title="Command-line arguments">

<deftable>
<tr><th>Argument<th>Meaning<th>Default
<tr><td>-verbose<td>Show the Java environment before starting Resin.<td>off
<tr><td>-conf <var/xxx/><td>Selects the Resin configuration file<td>conf/resin.conf
<tr><td>-java_home <var/xxx/><td>Sets the JDK (also recognizes the environment variable JAVA_HOME.)<td>A heuristic search 
<tr><td>-resin_home <var/xxx/><td>Sets the Resin home directory (also recognizes the environment variable RESIN_HOME.)<td>The parent directory of wrapper.pl
<tr><td>-classpath <var/xxx/><td>Adds to the system classpath.<td>$CLASSPATH
<tr><td>-pid <var/xxx/><td>(Unix) With <var/start/> or <var/stop/>, sets the file
to save the process id.<td>resin.pid
<tr><td>-stdout <var/xxx/><td>Sets the file to save stdout messages.<td>log/stdout.log.
<tr><td>-stderr <var/xxx/><td>Sets the file to save stdout messages.<td>log/stderr.log.
<tr><td>-D<var/my.foo/>=<var/value/><td>Sets a Java system property.<td>n/a
<tr><td>-X<var/xxx/><td>Passes the -X<var/xxx/> command to the JDK.<td>n/a
<tr><td>-J<var/xxx/><td>Passes <var/xxx/> as a JDK argument.<td>n/a
<tr><td>-nojit<td>Disables the Just-In-Time compiler. Useful for debugging.<td>enabled
<tr><td>start<td>(Unix) Starts Resin as a daemon, saving the pid in the pid file.<td>n/a
<tr><td>stop<td>(Unix) Stops Resin as a daemon, using the pid in the pid file.<td>n/a
<tr><td>restart<td>(Unix) Restarts Resin as a daemon, using the pid in the pid file.<td>n/a
<tr><td>-install<td>(NT) install Resin as a service (but doesn't automatically start.)<td>n/a
<tr><td>-install-as <var/xxx/><td>(NT) install Resin as a named service (but doesn't automatically start.)<td>n/a
<tr><td>-remove<td>(NT) install Resin as a service (but doesn't automatically start.)<td>n/a
<tr><td>-remove-as <var/xxx/><td>(NT) remove Resin as a named service (but doesn't automatically start.)<td>n/a
</deftable>

</section>

<section title='Starting Java directly'>

You can use the <var/-verbose/> flag to see the arguments the startup
scripts/executables pass to the JDK.  The main Java executable is
<var/com.caucho.server.http.HttpServer/> and starting Resin looks like
the following, once you've properly configured the classpath:

<example>
unix> java -Dresin.home=/usr/resin \
           com.caucho.server.http.HttpServer \
           -conf conf/resin.conf 
</example>
</section>

