大部分的时候都是一个resion跑一个应用,这样很容易管理,一天领导要求跑多个应用,无奈只能google,通过搜到的一些碎片,总算是成功的跑了三个应用,把过程记录下来以备不时之需,如果错误请指正。

环境:

os: ubuntu 11.04 64位


1. 安装jdk,并配置好环境变量:

2. 编译安装resion:

wget http://www.caucho.com/download/resin-3.1.11.tar.gz  tar -xvf resin-3.1.11.tar.gz  ./configure  make && make install

3. 配置应用目录:

mkdir web-appcd web-appmkdir app1 app2 app3

并在每个app文件夹下面放置好测试的index文件,直接拷贝nginx的index.html即可,并修改里面的body作为应用的标记,比如"This is app1" ...。

4. 编译安装nginx:

wget http://nginx.org/download/nginx-1.3.10.tar.gztar -xvf nginx-1.3.10.tar.gzln -s nginx-1.3.10 nginxcd nginx./configuremake && make install

   在编译的过程中,可能会遇到各种问题,其实就是缺少相应的依赖包,下面是我遇到的问题:

问题:./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=
option.解决办法:sudo apt-get install libpcre3-dev
问题:./configure: error: SSL modules require the OpenSSL library.You can either do not enable the modules, or install the OpenSSL libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=
option解决方法:sudo apt-get install libssl-dev
问题:make: *** No rule to make target `build', needed by `default'. Stop.解决方法:下载编译安装 pcrewget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz在编译pcre的时候,也可能遇到问题:configure: error: You need a C++ compiler for C++ support.解决方法:sudo apt-get install g++

5. resin的配置文件:

2s
.
.
.

6. nginx的配置文件:

#user  nobody;worker_processes  1;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {   worker_connections  1024;}http {   include       mime.types;      default_type  application/octet-stream;   sendfile        on;   keepalive_timeout  65;#gzip  on;   upstream app1 {      server 127.0.0.1:8081;   }   upstream app2 {          server 127.0.0.1:8082;   }   upstream app3 {                  server 127.0.0.1:8083;   }   upstream test {      server 127.0.0.1:8081;      server 127.0.0.1:8082;   }   server {      listen       80;      server_name  54.248.221.116;#charset koi8-r;#access_log  logs/host.access.log  main;#error_page  404              /404.html;# redirect server error pages to the static page /50x.html      location /app1 {         proxy_pass http://app1;         proxy_set_header X-Real-IP $remote_addr;      }      location /app2 {         proxy_pass http://app2;         proxy_set_header X-Real-IP $remote_addr;         index  index.html index.htm;      }      location /app3 {         proxy_pass http://app3;         proxy_set_header X-Real-IP $remote_addr;         index  index.html index.htm;      }}

7. 启动nginx和resin:

~/resin/bin/httpd.sh -server app1 start~/resin/bin/httpd.sh -server app2 start~/resin/bin/httpd.sh -server app3 startsudo /usr/local/nginx/sbin/nginx &

打开浏览器,访问 xxx.xxxx.xxx.xxx/app1 xxx.xxxx.xxx.xxx/app2 xxx.xxxx.xxx.xxx/app3

大功告成。