日期:2014-05-17  浏览次数:20646 次

在Apache下部署Redmine
转自:http://now-code.com/archives/523
在之前的一篇日志中,我整理了如何配置redmine,可以使其在webrick下运行,下面介绍如何将redmine部署到Apache上。

假设:
A. 我们已经完成了上一篇日志中的所有操作,且redmine可以正常启动!
B. 所有的软件环境与上一篇日志中配置相同。

1. 修改redmine运行环境参数
在/opt/redmine-1.2/config/environment.rb中加入以下行:
ENV['RAILS_ENV'] ||= 'production'

2. 重命名CGI文件
包括四个文件:
cd /opt/redmine-1.2/public
mv dispatch.cgi.example dispatch.cgi
mv dispatch.fcgi.example dispatch.fcgi
mv dispatch.rb.example dispatch.rb
mv htaccess.fcgi.example .htaccess

3. 安装passenger
我们使用passenger-3.0.8,可以使用gem命令和passenger-3.0.8.gem安装
gem install --local passenger-3.0.8.gem

4. 安装passenger的Apache模块
首先需要安装Apache开发包:
yum install httpd-devel

然后使用passenger的工具安装Apache模块:
passenger-install-apache2-module

5. 配置Apache,使其启动时加载passenger模块
在/etc/httpd/conf.d/目录下添加mod_passenger.conf文件,内容如下:
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.8
PassengerRuby /usr/local/bin/ruby

6. 创建指向/opt/redmine-1.2/public的软连接
ln -s /opt/redmine-1.2/public /var/www/html/redmine

7. 配置Apache中redmine部分
修改/etc/httpd/conf/httpd.conf文件,在其中加入以下内容:
RailsEnv production
RailsBaseURI /redmine
 
<directory "/var/www/html/redmine">
    Options Indexes MultiViews FollowSymLinks ExecCGI
    Order allow,deny
    Allow from all
    AllowOverride all
</directory>

8. 保证apache用户对于/opt/redmine-1.2的访问权限
修改权限如下:
chown -R apache:apache /opt/redmine-1.2
chown -R apache:apache /var/www/html/redmine

9. 重启Apache服务器
/etc/init.d/httpd restart

10. 测试是否成功
重启完成之后访问:http://hostname/redmine(hostname为您服务器的域名或者IP),如果出现redmine的界面,那么恭喜已经完成了所有配置;否则,请留言讨论。