日期:2014-05-16  浏览次数:20820 次

apache+resin+pureftp的虚拟主机和负载均衡

apache+resin+pureftp的虚拟主机和负载均衡[原创]


http://www.chinaunix.net 作者:peng??发表于:2009-05-12 13:12:15
【发表评论】【查看原文】【Linux讨论区】【关闭】
<!-- 正文begin -->

1、前言
??apache+resin来做想来大家都比较熟悉了,一般的配置都是很熟悉的了,我查看了一些论坛上的文章,这方便的文章比较多。在这里,我只要写写apache+resin实现独立的虚拟主机和resin自带的负载均衡。

2、系统和环境:
redhat9?and?solaris9
httpd-2.50
resin-3.06
pure-ftpd-1.0.17a.tar.gz
3、安装软件:

3.1、安装apache:

#?tar?zxvf?httpd-2.49.tar.gz
#?cd?httpd-2.49
#?./configure?--prefix=/usr/local/apache2?--enable-so?--with-mpm=worker
#?make
#?make?install

3.2、安装resin:

#?tar?zxvf?resin-3.06.tar.gz
#?cd?resin03.06
#?./configure?--prefix=/usr/local/resin?--with-apxs=/usr/local/apache2/bin/apxs
#?make
#?make?install

3.3、安装pureftp

#?tar?zxvf?pure-ftpd-1.0.17a.tar.gz?
#?cd?pure-ftpd-1.0.17a
#?./configure?--prefix=/usr/local/pureftpd
???--without-inetd?--with-puredb
???--with-cookie?--with-throttling
???--with-ratios?--with-quotas?
???--with-ftpwho?--with-largefile
???--with-welcomemsg
#?make
#?make?install
#?mkdir?/usr/local/pureftpd/etc

4、配置软件:

目的:用apache和resin做基于域名的虚拟主机,启用resin自身的负载均衡的引擎。resin的负载均衡引擎实际上是可以启动多个java响应进程,通过内部机制来进行负载均衡。

4.1、配置apache:

#?vi?/usr/local/apache2/conf/httpd.conf
---------------------------------------
?DirctoryIndex?index.html?index.jsp
?AddDefaultCharset?Off
?User?nobody
?Group?nobody
?NamevirtualHost?211.11.11.11
?<VirtualHost?211.11.11.11:80>;
????ServerAdmin?peng.zhang@bj.china.com
????DocumentRoot?/data/web/xcity
????ServerName?xcity.chinaunix.com
????ErrorLog?logs/xcity.chinaunix.com-error_log
????CustomLog?logs/xcity.chinaunix.com-access_log?common
</VirtualHost>;

<VirtualHost?211.11.11.11:80>;
????ServerAdmin?peng.zhang@bj.china.com
????DocumentRoot?/data/web/sports
????ServerName?sports.chinaunix.com
????ErrorLog?logs/sports.chinaunix.com-error_log
????CustomLog?logs/sports.chinaunix.com-access_log?common
</VirtualHost>;
........
....
#?mod_caucho?Resin?Configuration
#

LoadModule?caucho_module?/usr/local/apache2/modules/mod_caucho.so

ResinConfigServer?127.0.0.1
---------------------------------------

4.2、配置resin:

#?vi?/usr/local/resin/conf/resin.conf
----------------------------------------

????<cluster>;
??????<srun?id="a"?host="127.0.0.1"?port="6801"?index="1"/>;
??????<srun?id="b"?host="127.0.0.1"?port="6802"?index="2"/>;
??????<srun?id="c"?host="127.0.0.1"?port="6803"?index="3"/>;
??????<srun?id="d"?host="127.0.0.1"?port="6804"?index="4"/>;
????</cluster>;

---注解:
(这里面,我用了系统本身的127.0.0.1,绑定了4个端口做伏在均衡。还可以用不同的ip地址和同一端口,来作。例如:
<cluster>;
??????<srun?id="a"?host="211.11.11.11"?port="6802"?index="1"/>;
??????<srun?id="b"?host="211.11.11.12"?port="6802"?index="2"/>;
??????<srun?id="c"?host="211.11.11.13"?port="6802"?index="3"/>;
??????<srun?id="d"?host="211.11.11.14"?port="6802"?index="4"/>;
????</cluster>;
还有些人,喜欢在apache中设置每一个java进程服务一个虚拟,这里我们不推荐,这样做,就会失去引擎本身的意义。)

<!--?configures?the?default?host,?matching?any?host?name?-->;
????<host?id='xcity.chinaunix.com'>;
??????<document-directory>;/data/web/xcity</document-directory>;
?????<!--?configures?the?root?web-app?-->;
?????<web-app?id='/'>;
????????<!--?adds?xsl?to?the?search?path?-->;
????????<class-loader>;
??????????<simple-loader?path="$host-root/xsl"/>;
?