事實上 FreeBSD 安裝很簡單,ports 都整理好了:
cd /usr/ports/www/rubygem-passenger
make config # "Use Nginx"
make install clean
不過這次因為 Redmine 卡在套件版本相依性,除了 Ruby 從 ports 裝,其他 RubyGems、Rails、Rake 都沒用 ports。好險裝 passenger 再編譯 nginx 模組沒想像中的困難。
安裝 passenger:
gem install passenger
裝好後 passenger 的資料會在 /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/ 目錄下,nginx 模組的程式碼會在底下的 ext/nginx/。
找到以後就可以準備編譯 nginx。到 /usr/ports/www/nginx 目錄下編輯 Makefile,在「CONFIGURE_ARGS」後加上 –add-module 參數:
CONFIGURE_ARGS+=--prefix=${ETCDIR}
--with-cc-opt="-I ${LOCALBASE}/include"
--with-ld-opt="-L ${LOCALBASE}/lib"
--conf-path=${ETCDIR}/nginx.conf
--sbin-path=${PREFIX}/sbin/nginx
--pid-path=${NGINX_RUNDIR}/nginx.pid
--error-log-path=${NGINX_ERRORLOG}
--user=${WWWOWN} --group=${WWWGRP}
--add-module=/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/nginx
接著 make install clean 便會自動將 passenger 模組編譯進去。
最後修改 nginx.conf:
http {
...
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9;
passenger_ruby /usr/local/bin/ruby;
passenger_max_pool_size 10;
...
server {
listen 80;
server_name my.site;
root /path/to/my/site;
passenger_enabled on;
passenger_use_global_queue on;
}
}
參考資料
Installing Passenger Nginx module on FreeBSD
http://www.snippety.org/articles/2009/05/16/installing-passenger-nginx-module-on-freebsd/
Phusion Passenger users guide, Nginx version
http://modrails.com/documentation/Users%20guide%20Nginx.html