Bookmark and Share

Lee's 程序人生

HTML CSS Javascript XML AJAX ATLAS C# C++ 数据结构 软件工程 设计模式 asp.net Java 数字图象处理 Sql 数据库
  博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

win下nginx0.7.64成功整合resin3.1.9(fastcgi方式)

Posted on 2010-02-22 13:43  analyzer  阅读(783)  评论(0编辑  收藏  举报

转:http://www.srstudio.com.cn/a/22

1.软件准备我这里下的都是稳定版本,初学没办法,dev版出点问题,咋解决都不知道,如果是在生产环境下,那更不用考虑了,直接下稳定版

下载jdk6  http://java.sun.com/javase/downloads/index.jsp

下载nginx0.7.64 http://nginx.org/en/download.html

下载resin3.1.9 http://www.caucho.com/download/

2.安装软件

安装jdk

解压ngxin,双击nginx.exe启动nginx

解压resin,双击httpd.exe启动nginx(不用setup.exe,如果是整合iis和apache可以先执行setup.exe)

保证 http://localhost  http://localhost:8080 能正常访问

3.nginx整合配置

我这边只做了简单的整合配置,所以不需要对resin进行任何设置,如果有复杂应用自行更改

打开nginx安装目录下的conf/nginx.conf,增加如下代码

[code]
...
http{
...
server {
#nginx监听端口
listen 80;
#为了方便快速开发访问,也为了模拟生产环境,我在win的C:\Windows\System32\drivers\etc\hosts文件下
#增加了127.0.0.1  ssh.com的配置 ,生产环境下有多个域名则可以这么配置
#server_name ssh.com www.ssh.com xxx.ssh.com;
server_name ssh.com;

location /{
#项目根目录
root K:\webapps\java\ssh;
#默认index文件
index index.html index.htm index.jsp;
}

location ~ (\.jsp)|(\.do)$ {
#根据后缀来判断是不是代理到resin执行,比如struts2 那么还需要增加.action后缀
proxy_pass  http://ssh.com:8080;
}

location ~ (\.jsp)|(\.do)$ {
root K:\webapps\java\ssh;
#resin端口
fastcgi_pass   127.0.0.1:8080;
fastcgi_index  index.jsp;
#这里只需要改对应的目录就可以了,linux也是如此
fastcgi_param  SCRIPT_FILENAME  K:\webapps\java\ssh$fastcgi_script_name;
include        fastcgi_params;
}

}
}
[/code]

好了 ,接下来在项目目录放两个文件按index.html index.jsp来进行测试

访问http://ssh.com显示html内容
访问http://ssh.com/index.jsp显示jsp内容
都能正常显示 说明整合成功

我要啦免费统计