Resin web server
From Resin 3.0
m (Protected "Resin web server" [edit=sysop:move=sysop]) |
Latest revision as of 17:21, 9 January 2009
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
- This was a problem with 3.1.6, but seems to have been fixed in 3.2.0.
Please note that on OS X, the above will not copy the JNI libraries anywhere such that they will be loaded when resin starts. What results is a message in one of resin's log files along the lines of, "Socket JNI library is not available. To compile the Socket JNI library on Unix, use ./configure; make; make install." To address this, copy the .jnilib files, which should be in the resin/libexec directory, to /Library/Java/Extensions in order for any user, including root, to pick them up. If you're running resin with a particular user, i.e. for local development, you can put them into that user's local ~/Library/Java/Extensions.
- This was a problem with 3.1.6, but seems to have been fixed in 3.2.0.
- 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.
= See also
- Linux service
- installing Resin as a Linux service
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
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.