|
Resin provides a fast servlet runner for Apache, allowing Apache to run servlets and JSP files. The servlet runner needs Apache 1.3.x and DSO support.
To configure Resin with Apache, you must follow the following steps:
Compiling ApacheYou need a version of Apache with DSO support enabled. Apache has full documentation at http://httpd.apache.org/docs/dso.html. Many distributions, e.g. Red Hat Linux, will have Apache preinstalled. However, because the standard distribution has files all over the place, some people prefer to recompile Apache from scratch. Once you untar Apache, build it like:
Solaris versions of Apache may need additional flags, otherwise you'll get some linking errors when trying to load Resin. You may need to refer to the Apache documentation if you get linking errors. Here's an example configuration on Solaris:
Compiling mod_caucho.soTo compile and install on Unix, you'll need to run Resin's configure and then make. This step will create mod_caucho.so and put it in the Apache module directory. Usually, mod_caucho.so will end up in /usr/local/apache/libexec/mod_caucho.so.If you know where your executable is, you can use --with-apxs. is a little Perl script that the Apache configuration makes. It lets modules like Resin know how all the Apache directories are configured. It is generally in /usr/local/apache/bin/apxs or /usr/sbin/apxs. It's usually easiest to use --with-apxs so you don't need to worry where all the Apache directories are.
Even if you don't know where is, the configure script can often find it:
As an alternative to --with-apxs, if you've compiled Apache yourself, or if you have a simple configuration, you can generally just point to the Apache directory:
The previous --with-apxs or --with-apache should cover most configurations. For some unusual configurations, you can have finer control over each directory with the following arguments to ./configure. In general, you should use --with-apache or --with-apxs, but the other variables are there if you know what you're doing.
Configure the EnvironmentIf you don't already have Java installed, you'll need to download a JDK and set some environment variables. Here's a typical environment that you might put in ~/.profile or /etc/profile
Configuring resin.confBy 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 . Change from 'doc' to something like '/usr/local/apache/htdocs'.
Starting the Servlet EngineNow you need to start the servlet engine. Starting Resin is the same with Apache or standalone. See the httpd page for a detailed description.
Resin will print every port it's listening to. In the above example, Resin is listening to port 8080 using HTTP and 6802 using its servlet runner protocol. In other words, mod_caucho can connect to Resin with 6802 only on same host, but you can browse port 8080 from any host. The following snippet shows the and configuration for the above example.
Testing the servlet engineCreate a test file '/usr/local/apache/htdocs/test.jsp'
Browse http://localhost/test.jsp again. You should now get
Making mod_caucho will automatically change your httpd.conf file. 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 to make sure you match the Apache configuration with the Resin configuration.
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. Restart Apache. Now browse http://localhost/caucho-status. It should return a table indicating that the servlet runner is stopped. Browse http://localhost/test.jsp. It should return a message like:
You can also dispatch to Resin directly from the httpd.conf. The apache handler name is "caucho-request".
Requests dispatched directly from the Apache httpd.conf will not appear in /caucho-status. You can use caucho-request as follows:
Virtual HostsThe virtual host topic describes virtual hosts in detail. If you're using a single JVM, you only need to configure the resin.conf. If you want a different JVM for each virtual host, your httpd.conf can load a different resin.conf for each JVM:
The foo.conf might look something like:
Dispatchingmod_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.
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.
When mod_caucho can't reach any JVM, it will send a default error page. Sites can customize the error page with the directive in the resin.conf.
|