Resin web server
From Resin 3.0
Contents |
Unix (including MacOS-X)
Getting started
(prompt) tar -xzvf resin-pro-3.0.x.tar.gz (prompt) cd resin-pro-3.0.x (prompt) ./configure; make; make install (prompt) bin/httpd.sh Resin-3.0.x (built Fri, 03 Feb 2006 09:47:48 EST) Copyright(c) 1998-2006 Caucho Technology. All rights reserved. Starting Resin on Mon, 13 Feb 2006 20:16:19 -0500 (EST) [20:16:23.367] Server[] starting ... [20:16:23.453] http listening to *:8080 ...
The following steps will start Resin for development:
- Install JDK 1.4 or later and link /usr/java to the Java home or set environment variable JAVA_HOME.
- Download Resin from the [download] page
- Untar resin-pro-3.0.x.tar.gz
- Change directory to resin-pro-3.0.x
- Build Resin ./configure; make; make install
- Execute bin/httpd.sh
- Browse http://localhost:8080
./configure options
- Main article: configure script
Option | Description |
---|---|
--enable-64bit | compiles the JNI using 64-bits |
The 64-bit JNI compilation must match the JDK you're using. The --enable-64bit compiles the JNI code as 64 bit. When starting Resin with httpd.sh, pass the -J-d64 option.
bin/httpd.sh
- Main article: httpd.sh
bin/httpd.sh is the script for starting the web server.
Developers commonly execute httpd.sh in a cmd window and log messages are displayed on the console.
(prompt) bin/httpd.sh
Deploying
- See also: site structure
It is a good idea to create a bit of structure to make Resin and website upgrades easier and more maintainable. In particular the -server-root option provides the ability to create a maintainable file structure for your website.
- Create a user to run Resin (e.g. resin or another non-root user)
- Link /usr/local/resin to the current Resin version.
- Create a deployment root, e.g. /var/www, owned by the resin user. This is -server-root.
- Put the modified resin.conf in /var/www/conf/resin.conf
- Put the site documents in /var/www/webapps/ROOT/
- Access logs will appear in /var/www/logs/
- Output logs will appear in /var/www/log/
- Put any .war files in /var/www/webapps/
- Virtual hosts are created by adding directories in /var/www/hosts/, e.g. /var/www/hosts/gryffindor.hogwarts.com/ and /var/www/hosts/slytherin.hogwarts.com/
- Create a daemon startup script and configure the server to start it when the machine reboots.
Site specific daemon script
- Main article: daemon
httpd.sh accepts the start, stop, and restart options for executon as a daemon.
You can create your own daemon script which will start and stop your Resin instance, and pass any command-line options. This script can be placed in /etc/init.d and work cooperatively with the operating systems standard daemon control system. The script typically does a number of things:
- Configures the location of Java in JAVA_HOME
- Configures the location of Resin in RESIN_HOME
- Configures your web site directory in SERVER_ROOT
- Selects a server and pid file if you have multiple Resin servers.
- Starts and stops the Resin daemon.
An example is included in the Resin distribution resin-pro-3.0.x/contrib/init.resin.
A simple daemon script looks like:
#!/bin/sh JAVA_HOME=/usr/java RESIN_HOME=/usr/local/resin SERVER_ROOT=/usr/local/web export JAVA_HOME export RESIN_HOME export SERVER_ROOT $RESIN_HOME/bin/httpd.sh -server-root $SERVER_ROOT \ -conf $SERVER_ROOT/conf/resin.conf \ -server a -pid $SERVER_ROOT/a.pid \\ $*
The script is invoked with ./resin start to start and ./resin stop to stop.
The -server and -pid options are only necessary if you have multiple JVMs either on different machines or the same machine. The load balancing and distributed sessions topics describe usage of -server and -pid.
Port forwarding
- Main article: Port forwarding
Unix systems require root privileges to bind to ports less than 1024. Running the Resin process as root is not advised for security reasons. Port forwarding details operating system specific techniques for forwarding privileged ports to the ports that Resin is bound to.
Windows
Getting started
- Install JDK 1.4 or later.
- Make sure the JDK installation set the environment variable JAVA_HOME correctly
- Unzip resin-3.0.x.zip
- Execute resin-3.0.x\httpd.exe
- Browse http://localhost:8080
(prompt) cd resin-pro-3.0.x (prompt) httpd.exe Resin-pro-3.0.x (built Fri, 03 Feb 2006 09:47:48 EST) Copyright(c) 1998-2006 Caucho Technology. All rights reserved. Starting Resin on Mon, 13 Feb 2006 20:16:19 -0500 (EST) [20:16:23.367] Server[] starting ...
httpd.exe
- Main article: httpd.exe
httpd.exe is the script for starting the web server.
Developers commonly execute httpd.exe in a cmd window and log messages are displayed on the console.
(prompt) httpd.exe
Deploying
- See also: site structure
It is a good idea to create a bit of structure to make Resin and website upgrades easier and more maintainable. In particular the -server-root option provides the ability to create a maintainable file structure for your website.
Windows service
{{main|Windows service||
The Resin Web Server can be installed as a Windows service. To install the service, use:
(prompt) httpd.exe -install -conf conf/resin.conf
Command-line options
- Main article: command line option
Option | Description | Default |
---|---|---|
-verbose | Show the Java environment before starting Resin. | off |
-conf xxx | Selects the Resin configuration file | conf/resin.conf |
-java_home xxx | Sets the JDK (also recognizes the environment variable JAVA_HOME.) | A heuristic search |
-resin_home xxx | Sets the Resin home directory (also recognizes the environment variable RESIN_HOME.) | The parent directory of wrapper.pl |
-classpath xxx | Adds to the system classpath. | $CLASSPATH |
-pid xxx | (Unix) With start or stop, sets the file to save the process id. | resin.pid |
-stdout xxx | Sets the file to save stdout messages. | log/stdout.log. |
-stderr xxx | Sets the file to save stdout messages. | log/stderr.log. |
-Dmy.foo=value | Sets a Java system property. | n/a |
-Xxxx | Passes the -Xxxx command to the JDK. | n/a |
-Jxxx | Passes xxx as a JDK argument. | n/a |
-nojit | Disables the Just-In-Time compiler. Useful for debugging. | enabled |
start | (Unix) Starts Resin as a daemon, saving the pid in the pid file. | n/a |
stop | (Unix) Stops Resin as a daemon, using the pid in the pid file. | n/a |
restart | (Unix) Restarts Resin as a daemon, using the pid in the pid file. | n/a |
-install | (Windows) install Resin as a service (but doesn't automatically start.) | n/a |
-install-as xxx | (Windows) install Resin as a named service (but doesn't automatically start.) | n/a |
-remove | (Windows) install Resin as a service (but doesn't automatically start.) | n/a |
-remove-as xxx | (Windows) remove Resin as a named service (but doesn't automatically start.) | n/a |
Memory configuration
- Main article: Command line options#Memory settings
Memory configuration is part of the JVM's options. For most JVMs, you can find the full list by starting "java -X".
-Xms<size> | Initial Java heap size, e.g. -Xms32m |
-Xmx<size> | Maximum Java heap size, e.g. -Xmx128m |
Starting Java directly
You can use the -verbose option to see the arguments the startup scripts/executables pass to the JDK. The IDE section also contains information about starting Resin directly from Java.