緊接前文,我希望能夠用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 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. 開啟網頁測試,通過!!!