Passenger实现Redmine和Apache集成

三月 9, 2010 in Ruby/Ruby on Rails

Redmine 0.9.3默认使用RoR自带的web服务器WEBrick,默认的端口是3000,很多人将Redmine集成到apache,nginx或tomcat中,集成到apache通常采用CGI方式来集成,配置起来比较繁杂。Phusion Passenger组件是专门为apache和nginx开发的用来部署Ruby on Rails应用的,配置起来非常的方便,使用下来感觉页面的操作速度比WEBrick要快很多,本文记录了如何安装passenger来集成Redmine到apache服务器。

环境信息:

  1. CentOS5
  2. Redmine 0.9.3
  3. Passenger 2.2.11

一,安装passenger

http://www.modrails.com/ 下载passenger安装程序之后,passenger-2.2.11.tar.gz,解压并运行

tar –xvf passenger-2.2.11.tar.gz
./bin/passenger-install-apache2-module

安装提示进行安装,如果系统中缺少必备的库,安装程序会给出提示,安装指示先进行相关的安装

* To install GNU C++ compiler:
Please run yum install gcc-c++ as root.
* To install Apache 2 development headers:
Please run yum install httpd-devel as root.
* To install Apache Portable Runtime (APR) development headers:
Please run yum install apr-devel as root.
* To install Apache Portable Runtime Utility (APU) development headers:
Please download it from
http://httpd.apache.org/
(APR Utility is an integrated part of Apache.)
If the aforementioned instructions didn’t solve your problem, then please take
a look at the Users Guide:
/u01/passenger-2.2.11/doc/Users guide Apache.html

 

如根据上面的提示在CentOS下更新相关的库:
yum install gcc-c++
yum install httpd-devel
yum install apr-devel

 

二,修改apache配置文件

passenger成功安装后,它会给出如下的配置提示信息,需要将它们添加到apache的配置文件 /etc/httpd/conf/httpd.conf

Please edit your Apache configuration file, and add these lines:
   LoadModule passenger_module /u01/passenger-2.2.11/ext/apache2/mod_passenger.so
   PassengerRoot /u01/passenger-2.2.11
   PassengerRuby /usr/local/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
--------------------------------------------
Deploying a Ruby on Rails application: an example
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!

         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:
  /u01/passenger-2.2.11/doc/Users guide Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-) 

http://www.modrails.com/

根据上面的提示,添加Passenger的配置到httpd.conf中:
LoadModule passenger_module /u01/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /u01/passenger-2.2.11
PassengerRuby /usr/local/bin/ruby

在httpd.conf中添加虚拟主机:
<VirtualHost *:80>
  ServerName colla.oracleseeker.com
  ServerAdmin webmaster@xxxxxx.com
  DocumentRoot /u01/redmine-0.9.3/public
  ErrorLog logs/redmine_error_log

  <Directory “/u01/redmine-0.9.3/public”>
    Options Indexes ExecCGI FollowSymLinks
    Order allow,deny
    Allow from all
    AllowOverride all
  </Directory>
</VirtualHost>

 

三、重启apache

/etc/init.d/httpd restart

相关文章:

  1. 基于RoR的项目协作平台Redmine
  2. CentOS5下安装Redmine0.9.3

Leave a reply

You must be logged in to post a comment.