Freebsd 下 整合 apache2 和 resin3

原创 2004年10月16日 01:24:00

Resin with Apache on Unix
To configure Resin with Apache, you must follow the following steps:
1. Compiling Apache
2. Compile
3. Configure Apache
4. Set up environment
5. Configure resin.conf
6. Restart Apache and start srun
Compiling Apache
You need a version of Apache with DSO support enabled. Apache has full documentation at
their website. To check if your apache has DSO support, you can check for mod_so.c in your
your httpd
checking apache httpd for mod_so.c
unix> /usr/local/apache/bin/httpd -l
Compiled-in modules:
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
Once you untar Apache, build it like:
unix> ./configure --prefix=/usr/local/apache /
unix> make
unix> make install
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:
unix> ./configure --prefix=/usr/local/apache /
--enable-rule=SHARED_CORE /
--enable-rule=SHARED_CHAIN /
--enable-module=so /
Resin 3.0 Installation - p. 14
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 14 -
--enable-module=most /
To compile and install mod_caucho on Unix, you'll need to run Resin's configure and then
make. This step will create and put it in the Apache module directory. Usually, will end up in /usr/local/apache/libexec/
If you know where your apxs executable is, you can use --with-apxs. 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
unix> ./configure --with-apxs=/usr/local/apache/bin/apxs
unix> make
Even if you don't know where apxs is, the configure script can often find it:
unix> ./configure --with-apxs
unix> make
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:
unix> ./configure --with-apache=/usr/local/apache
unix> make
unix> make install
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.
--with-apache=dir The Apache root directory.
--with-apxs=apxs Pointer to the Apache extension script
--with-apache-include=dir The Apache include directory
--with-apache-libexec=dir The Apache module directory
--with-apache-conf=httpd.conf The Apache config file
Configure the Environment
Resin 3.0 Installation - p. 15
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 15 -
If 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
# Java Location
export JAVA_HOME
# Resin location (optional). Usually Resin can figure this out.
# If you're using additional class libraries, you'll need to put them
# in the classpath.
Configuring resin.conf
The default resin.conf, looks in resin-3.0.x/doc for JSP files and
resin-3.0.x/doc/WEB-INF/classes for servlets and beans. To tell Resin to use Apache's
document area, you configure the document-directory. Change document-directory from 'doc' to
something like '/usr/local/apache/htdocs'.
<resin xmlns="">
<host id="">
Starting the Servlet Engine
Now you need to start the servlet engine. Starting Resin is the same with Apache or standalone.
See the httpd page for a detailed description.
unix> resin-3.0.x/bin/
Resin 3.0.2-beta (built Mon Aug 4 09:26:44 PDT 2003)
Copyright(c) 1998-2003 Caucho Technology. All rights reserved.
Starting Resin on Mon, 04 Aug 2003 09:43:39 -0700 (PDT)
[09:43:40.664] Loaded Socket JNI library.
[09:43:40.664] http listening to *:8080
[09:43:40.664] ServletServer[] starting
Resin 3.0 Installation - p. 16
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 16 -
[09:43:40.879] hmux listening to *:6802
[09:43:41.073] Host[] starting
[09:43:41.446] Application[http://localhost:8080/resin-doc] starting
[09:43:41.496] Application[http://localhost:8080] starting
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 <http> and <srun> configuration for the above example.
<resin xmlns="">
<http id="" host="*" port="8080"/>
<srun id="" host="localhost" port="6802" index="1"/>
Testing the servlet engine
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
Configuring Apache by hand
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
LoadModule caucho_module libexec/
Resin 3.0 Installation - p. 17
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 17 -
<IfModule mod_caucho.c>
ResinConfigServer localhost 6802
<Location /caucho-status>
SetHandler caucho-status
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:
Cannot connect to Servlet Runner.
You can also dispatch to Resin directly from the httpd.conf. The apache handler name is
Apache Handler Meaning
caucho-status Handler to display /caucho-status
caucho-request Dispatch a request to Resin
Requests dispatched directly from the Apache httpd.conf will not appear in /caucho-status. You
can use caucho-request as follows:
<Location /foo/*>
SetHandler caucho-request
Apache Command Meaning
ResinConfigServer host port Specifies the Resin JVM at host:port as a
configuration server.
CauchoStatus true/false Enables/disables the /caucho-status
Virtual Hosts
The 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:
Resin 3.0 Installation - p. 18
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 18 -
ResinConfigServer 6802
ResinConfigServer 6802
The foo.conf might look something like:
<resin xmlns="">
<srun id="" host="" port="6802"/>
<host id=''>
mod_caucho queries the configuration server to distinguish the URLs going to Resin from the
URLs handled by Apache. The configuration server uses the <servlet-mapping> directives to
decide which URLs to send. Also, any *.war file automatically gets all its URLs. Other URLs stay
with Apache. There's a more complete discussion of the URL dispatching in the plugin-dispatch
Load Balancing
In Resin 3.0, 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 xmlns="">
Resin 3.0 Installation - p. 19
Copyright (c) 1998-2004 Caucho Technology. All rights reserved
- 19 -
<srun id="a" host="host1" port="6802" index="1"/>
<srun id="b" host="host2" port="6802" index="2"/>
<srun id="c" host="backup" port="6802" index="3" backup="true"/>



通常情况下,如果PHP业务和Java Web业务占用资源都不是很多的情况下,为了节省服务器开销,可以放到一台服务器上。此时可以利用Nginx依旧80端口,做一个请求转发来分别访问PHP应用和Java ...
  • nowadaysall
  • nowadaysall
  • 2016年11月09日 16:17
  • 878

Ubuntu Apache2 与Tomcat 7 整合步骤

写在前面 网上已经有很多关于如何整合Apache2与Tomcat的文章, 但有时看
  • monkeyking1987
  • monkeyking1987
  • 2014年05月14日 11:02
  • 5503

Ubuntu 14.04 整合Apache2与Tomcat7

安装hustoj和VirtualJudge后,想着把他们弄在一起,因为端口号太多访问者着实不方便。下面的教程中有些省略了,可以在前面几篇帖子找到。 网上已经有很多关于如何整合Apache2与Tomca...
  • cnylsy
  • cnylsy
  • 2016年09月08日 20:34
  • 798


1. Linux 优点: 充分发挥 PC 的功能,花样极多,玩起来很有趣,各方面的表现都不错。 缺点: 太过自由,以致於发散掉了,维护方面比 FreeBSD 麻烦(对一般人来说)。 -> 适合喜欢「玩...
  • charleyhuman
  • charleyhuman
  • 2006年10月02日 16:02
  • 2431


注意:本文出自 “阿飞”的博客 ,如果要转载本文章,请与作者联系! 并注明来源: ...
  • faye0412
  • faye0412
  • 2012年09月29日 11:06
  • 3761

Linux Apache+Tomcat 整合(JK方式)

版本:请注意如果整合时一定要看,apache和tomcat的官方文档,版本不一样,整合细节也不太一样 Apache: 2.2.21 Tomcat: 6.0.33 mod_jk: 1.2.32 ...
  • StellaAh
  • StellaAh
  • 2012年10月26日 18:18
  • 2242


根据链接tomcat的方法配置了在eclipse里配置了服务器resin3(如下:)window----Preferences---MyEclipse---Application servers---...
  • eyejava
  • eyejava
  • 2007年03月29日 17:52
  • 2645


更新源: apt-get update 安装apache2: apt-get install apache2 安装libapache2-mod-jk: apt-get install liba...
  • shooray
  • shooray
  • 2015年12月09日 14:55
  • 1440


 经过2天的无数次试验,泪奔中,终于安装完成,下面是我在centos6.5下安装php+mysql+apache并整合的具体流程: 1.源码安装apache(网上有教程),我安装的是httpd...
  • xjkwq1qq
  • xjkwq1qq
  • 2014年06月20日 10:26
  • 5300

resin3.10 resin4:多实例部署使用记录。

源于,公司一个项目的war包在tomcat部署没有问题。在resin3.10部署,找不到其他模块的一个类。 resin4.0.50多实例部署实例配置:第一个实例: ...
  • u010387163
  • u010387163
  • 2017年05月13日 14:32
  • 444
您举报文章:Freebsd 下 整合 apache2 和 resin3