您的位置:首页 > 运维架构 > Apache

搭建redmine全攻略——与apache整合(CentOS 5.8 64位)

2012-12-20 21:55 295 查看
前言

redmine(http://www.redmine.org/)是一款项目管理软件,由ruby编写,以网页的形式呈现。正好公司需要单独搭建一套这个系统,刚去实习没几天,也没见过redmine长什么样。第一次搭建,与其说是搭建,更应该说是升级。

任务:①在阿里云服务器上搭建redmine系统,我用的最新版redmine 2.1.4

   ②导入之前同事用redmine1.2.0搭建的数据,使用的是MySQL数据库。

安装

Step 1 - Redmine application

首先是软件的下载地址:redmine 2.1.4、ruby 1.8.7、rubygems 1.8.24

redmine:
http://rubyforge.org/frs/?group_id=1850
rubygems:
http://rubyforge.org/frs/?group_id=126&release_id=46730
ruby:
ftp://ftp.ruby-lang.org/pub/ruby/1.8/
需要安装的软件包

ruby-1.8.7.tar.gz

ruby-libs-1.8.5-24.el5(or later version) ruby的依赖包,虽然ruby版本版本是1.8.7,但是经过我的测试这个可以用1.8.5的,可以用yum安装,命令yum install ruby-libs。

rubygems-1.8.24.tgz

redmine-2.1.4.tar.gz

安装Ruby、RubyGems

tar zxf ruby-1.8.7.tar.gz

cd ruby-1.8.7

./configure --prefix=/usr/local/ruby

tar xf rubygems-1.8.24.tgz

cd rubygems-1.8.24

ruby setup.rb

加入ruby环境变量(这里有个疑惑是应该加在/root/.bash_profile里还是/etc/bashrc里)

vim /root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/ruby/bin

source /root/.bash_profile

tar zxf redmine-2.1.4.tar.gz

chown -R apache.apache redmine-2.1.4

cd redmine-2.1.4

Step 2 - Dependencies installation

gem install bundler #安装bundler,好处是不需要使用gem 一个一个的安装模块,坏处的不能控制版本。官网http://gembundler.com/

bundle install --without development test postgresql sqlite rmagick #without就是不安装这几个模块,其他都安装。

Step 3 - Create an empty database and accompanying user

MySQL下执行(MySQL要事先安装好,版本5.0及以上,可以直接使用yum安装,yum install mysql mysql-server mysql-devel)

create database redmine character set utf8;

create user 'redmine'@'localhost' identified by 'redmine';#在数据库中创建redmine用户,密码也是redmine

grant all privileges on redmine.* to 'redmine'@'localhost';

Step 4 - Database connection configuration

cd config

cp database.yml.example database.yml #配置redmine连接MySQL

vim database.yml

修改为:

production:

adapter: mysql

database: redmine

host: localhost

username: redmine

password: redmine

encoding: utf8

保存退出

cp configuration.yml.example configuration.yml

vim configuration.yml #配置邮件通知,前提是安装好sendmail或者postfix,同样可以用yum安装

修改:

#default 部分

default:

# Outgoing emails configuration (see examples above)

email_delivery:

delivery_method: :smtp

smtp_settings:

address: 127.0.0.1

port: 25

domain: localhost

authentication: :login

user_name: "redmine@localhost"

password: "redmine"

#production 部分

production:

email_delivery:

delivery_method: :smtp

smtp_settings:

address: 127.0.0.1

port: 25

domain: localhost

Step 5 - Session store secret generation

cd ..

rake generate_secret_token #生成config/initializers/secret_token.rb文件,在redmine 2.1.4中,这个文件事先是不存在的,如果有有了可以删除掉

Step 6 - Database schema objects creation

RAILS_ENV=production rake db:migrate #初始化数据库,创建表

Step 7 - Database default data set

RAILS_ENV=production rake redmine:load_default_data #插入缺省数据,选择zh

Step 8 - File system permissions

mkdir tmp tmp/pdf public/plugin_assets #主要是修改文件夹权限,如果有了可以不创建,只修改权限和属主

chown -R apache:apache files log tmp public/plugin_assets

chmod -R 755 files log tmp public/plugin_assets

Step 9 - bind with apache #跟apache整合,需要安装httpd、httpd-devel

gem install passenger

passenger-install-apache2-module

touch /etc/httpd/conf.d/redmine.conf

写入内容(这个根据实际情况复制,passenger-install-apache2-module命令执行成功会有提示)

LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.18/ext/apache2/mod_passenger.so

PassengerRoot /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.18

PassengerRuby /usr/local/ruby/bin/ruby

Listen 3000

<VirtualHost *:3000>

ServerName server.example.com #换成你自己的主机名

# !!! Be sure to point DocumentRoot to 'public'!

DocumentRoot /opt/redmine-2.1.4/public

<Directory /opt/redmine-2.1.4/public >

# This relaxes Apache security settings.

AllowOverride all

# MultiViews must be turned off.

Options -MultiViews

</Directory>

</VirtualHost>

/etc/init.d/httpd restart #启动apache,这样redmine也就启动了

Step 10 - Finish
http://server.example.com:3000/
备注:

导出mysql数据库内容

mysqldump -uroot -ppassword redmine --lock-all-tables >redmien.sql

导入数据库内容

mysql -uroot -ppassword redmine <redmine.sql

更新redmine数据库

rake generate_secret_token

rake db:migrate RAILS_ENV=production

rake redmine:plugins:migrate RAILS_ENV=production

常见问题:

①解决redmine中导出项目问题时候报错。如下

Error with the Atom/PDF/CSV export function

I have find the problem:

Array(Mime[parameters[:format]])

the Array() method is not working, which require method: to_ary

solution:
1. actionpack (3.2.6) lib/action_dispatch/http/mime_negotiation.rb:55
change from Array(Mime[parameters[:format]])
to Array.wrap(Mime[parameters[:format]])

②插件安装

在官网上下载相关插件,将redmine插件解压,整个目录复制到redmine根目录的plugins目录下

然后执行rake redmine:plugins:migrate RAILS_ENV=production就OK了。它会在数据库中建立相关的表。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: