Nginx和Redmine

来源:互联网 发布:mysql 最小值 编辑:程序博客网 时间:2024/05/01 06:55

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

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

1. 安装需要的开发库

apt-get install libfcgi-dev

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

gem "fcgi"

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

bundle install --without development test

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

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

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

apt-get install spawn-fcgi

6. 启动:

cp public/dispatch.fcgi.example public/dispatch.fcgispawn-fcgi -p 9001 -f ./public/dispatch.fcgi


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

root@redmine:~/redmine-2.3# fuser -n tcp 90019001/tcp:            26510root@redmine:~/redmine-2.3# ps -def | grep dispatchroot     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. 打开网页测试,通过!!!

如果想支持HTTPS,可以像下面这样在Nginx的conf.d目录下创建一个redmin.conf文件

server {    listen       443;    server_name  your_domain_name    ssl                  on;    ssl_certificate ./conf.d/server.crt;    ssl_certificate_key ./conf.d/server.key;    location = /favicon.ico {        log_not_found off;        log_subrequest off;    }    # 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;    }}

注意,还有另一种方式,通过passenger,请参考别人的文章。 因为经过实际运用,我的方式有时候redmine 会crash, 而且我还没有找到原因,因为我对ruby on rails不熟悉。

http://www.cnblogs.com/csharpsharper/p/3250913.html

https://forums.freebsd.org/viewtopic.php?&t=41256

原创粉丝点击