现在的位置: 首页 > 综合 > 正文

Redmine启用FastCGI

2013年10月12日 ⁄ 综合 ⁄ 共 797字 ⁄ 字号 评论关闭

紧接前文,我希望能够用FastCGI协议和Nginx交互,这样就能用在产品环境下。

Redmine启用FastCGI文档不全,靠自己揣摩和Google得到的零散信息,得到如下配置方法:

1. 安装需要的开发库

apt-get install libfcgi-dev

2. 在redmine目录下创建文件Gemfile.locale, 内容如下:

gem "fcgi"

3. 安装依赖,再次运行下面的命令:

bundle install --without development test

4. 强制环境变量为production,在conf/environment.rb中第一行添加:

ENV['RAILS_ENV'] ||= 'production'

5. 安装启动fastcgi的工具软件

apt-get install spawn-fcgi

6. 启动:

spawn-fcgi -p 9001 -f ./public/dispatch.fcgi

现在检查一下是否监听了9001端口:

root@redmine:~/redmine-2.3# fuser -n tcp 9001
9001/tcp:            26510
root@redmine:~/redmine-2.3# ps -def | grep dispatch
root     26510     1  2 12:53 ?        00:00:04 ruby ./public/dispatch.fcgi

7. 现在假定已经安装了Nginx,在conf.d/default.conf文件中添加几行配置:

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9001                                                                                                         
    location / {                                                                                                                    
	fastcgi_pass   127.0.0.1:9001; 
	fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
	include        fastcgi_params;
    }

8. 打开网页测试,通过!!!

抱歉!评论已关闭.