分享
 
 
 

Freebsd 下 整合 apache2 和 resin3

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Resin with Apache on Unix

Installation

To configure Resin with Apache, you must follow the following steps:

1. Compiling Apache

2. Compile mod_caucho.so

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:

...

mod_so.c

...

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:

unix> ./configure --prefix=/usr/local/apache --enable-module=so

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 --enable-shared=max

Compiling mod_caucho.so

To compile and install mod_caucho 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 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

are.

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

JAVA_HOME=/<installdir>/jdk1.4

export JAVA_HOME

# Resin location (optional). Usually Resin can figure this out.

RESIN_HOME=/<installdir>/resin-3.0.2

export RESIN_HOME

# If you're using additional class libraries, you'll need to put them

# in the classpath.

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.conf

<resin xmlns="http://caucho.com/ns/resin">

<server>

<host id="">

<document-directory>/usr/local/apache/htdocs</document-directory>

...

</host>

</server>

</resin>

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/httpd.sh

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://caucho.com/ns/resin">

<server>

<http id="" host="*" port="8080"/>

<cluster>

<srun id="" host="localhost" port="6802" index="1"/>

</cluster>

...

</server>

</resin>

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

configuration.

httpd.conf

LoadModule caucho_module libexec/mod_caucho.so

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

</Location>

</IfModule>

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

"caucho-request".

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

</Location>

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

management

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:

httpd.conf

Resin 3.0 Installation - p. 18

Copyright (c) 1998-2004 Caucho Technology. All rights reserved

- 18 -

<VirtualHost foo.com>

ServerName foo.com

ServerAlias www.foo.com

ResinConfigServer 192.168.0.1 6802

</VirtualHost>

<VirtualHost bar.com>

ServerName bar.com

ServerAlias www.bar.com

ResinConfigServer 192.168.0.2 6802

</VirtualHost>

The foo.conf might look something like:

foo.conf

<resin xmlns="http://caucho.com/ns/resin">

<server>

<cluster>

<srun id="" host="192.168.0.2" port="6802"/>

</cluster>

<host id='www.foo.com'>

...

</host>

</server>

</resin>

Dispatching

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

page.

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.conf

<resin xmlns="http://caucho.com/ns/resin">

<server>

Resin 3.0 Installation - p. 19

Copyright (c) 1998-2004 Caucho Technology. All rights reserved

- 19 -

<cluster>

<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"/>

</cluster>

...

</server>

</resin>

呵,,就是我的目录有点不同,不过总算可以了,

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有