版本对应:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
官方安装教程:http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_on_CentOS_5
redmine一键安装包:http://bitnami.org/stack/redmine
一.软件准备
redmine 打开http://rubyforge.org/frs/?group_id=1850,下载自己所需的版本
mysql http://www.mysql.com/downloads/mysql/5.1.html#downloadsRuby http://www.ruby-lang.org/en/downloads/
二.安装相关软件
1.安装数据库
wget -c http://cdn.mysql.com/Downloads/MySQL-5.1/MySQL-server-5.1.67-1.glibc23.i386.rpm
wget -c http://cdn.mysql.com/Downloads/MySQL-5.1/MySQL-devel-5.1.67-1.glibc23.i386.rpm
wget -c http://cdn.mysql.com/Downloads/MySQL-5.1/MySQL-client-5.1.67-1.glibc23.i386.rpm
rpm -ivh MySQL-server-5.1.67-1.glibc23.i386.rpm
rpm -ivh MySQL-devel-5.1.67-1.glibc23.i386.rpm
rpm -ivh MySQL-client-5.1.67-1.glibc23.i386.rpm
安装完成后,创建一个redmine的数据库和帐户,并授予此帐户对redmine的数据库拥有所有权限。
CREATEDATABASE redmine CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANTALL on redmine.* TO redmine@'localhost' IDENTIFIED BY 'redmine';
2.安装ruby
tar zxf ruby-1.9.2-p0.tar.gz
cd ruby-1.9.2-p0
./configure --prefix=/usr/local/ruby
make && make install
ln -s /usr/local/ruby/bin/ruby /usr/bin/ruby
ln -s /usr/local/ruby/bin/gem /usr/bin/gem
ln -s /usr/local/ruby/bin/rails /usr/bin/rails
ln -s /usr/local/ruby/bin/rake /usr/bin/rake
更新rubyGem
gem update --system
或者:
详细请参考:http://rubygems.org/pages/download$ gem install rubygems-update # again, might need to be admin/root
$ update_rubygems # ... here too
3.安装redmine
wget http://files.rubyforge.vm.bytemark.co.uk/redmine/redmine-2.2.0.tar.gz
mv redmine-2.2.0.tar.gz /opt
cd /opt
tar zxf redmine-2.2.0.tar.gz
mv redmine-2.2.0 redmine
cd redmine
gem update --system
gem install bundler
/usr/local/ruby/bin/bundle install --without development test rmagick postgresql sqlite
4.初始化数据库
修改数据库配置文件,这里使用的是mysql数据库,由于ruby的版本为1.9。所有adapter为mysql2, 如果版本为1.8的话,由直接写mysql即可。
5. 生成会员存储密码cp config/database.yml.example config/database.yml
vi config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: my_password
RAILS_ENV=production rake config/initializers/session_store.rb
redmine r3055之后的版本移除了config/initializers/session_store.rb,使用下面的命令替代。
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
6.配置redmine
配置文件为 configuration.yml
启动redmine ruby /opt/redmine/script/rails server webrick -e production -p 80 -dcp config/configuration.yml.example config/configuration.yml
可以做个redmine的启动脚本:
echo '#change the -p number to change the port!'>>redserver
echo "ruby /opt/redmine/script/rails server webrick -e production -p 80 -d">>redserver
然后chmod +x redserver
Redmine里邮件配置:
vi config/configuration.yml
default:
# Outgoing emails configuration (see examples above)
email_delivery:
delivery_method: :smtp
smtp_settings:
address: smtp.qq.com
port: 25
domain: qq.com
authentication: :login
user_name: "123456@qq.com"
password: "blog.haohtml.com"
7.redmine与nginx的整合
默认情况下,访问redmine需要通过http://ip:port的形式来打开,为方便用户,需要用域名的方法直接打开redmine,此时就需要nginx与redmine的整合了。
nginx与redmine的整合有两种方法
(1).设置nginx代理来通过域名访问redmine,更改nginx的配置文件,加入下面语句
upstream redmin {
server 192.168.1.180:8080;
}
server {
listen 80;
server_name redmine.test.com;
location /
{
proxy_next_upstream http_502http_504 error timeout invalid_header;
proxy_pass http://redmin;
proxy_set_header Hostredmine.test.com;
proxy_set_headerX-Forwarded-For $remote_addr;
}
access_log /var/www/redmine/log/access.log;
}
然后更改本机hosts,加入192.168.1.180 redmine.test.com即可直接通过redmine.test.com来打开redmine工作平台。
(2).通过nginx的一个passenger模块来实现
首先,安装此支持:
gem install passenger
如果nginx已经安装好,通过/usr/local/nginx/sbin/nginx -V查看先前安装nginx的时候所加参数,然后重新编译,在执行./configure的时候除原来参数外,另加--add-module=/usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/nginx,命令结束后进行编译:make。编译完成后,在源代码的objs目录下会有一个nginx的执行文件,这时,备份原来的nginx,防止发生意外。
mv /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.old
cp -a objs/nginx /usr/local/nginx/sbin/
检测nginx
/usr/local/nginx/sbin/nginx -t
如果没有问题,说明一切正常。
编辑nginx配置文件nginx.conf
加入以下内容:
passenger_root/usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11;
passenger_ruby /usr/local/ruby/bin/ruby;
server{
listen 80;
server_name redmine.test.com;
root /var/www/redmine/public;
passenger_enabled on;
rails_env production;
access_log on;
}
最后,可在本机更改host,加入下面一条记录:
192.168.1.180 redmine.test.com
即可通过域名来访问redmine。
常见问题:
1.安装mysql-2.8.1.gem的时候出现很多下面错误
No definition for next_result
先安装rdoc,然后再安装mysql就可以了。
2.在执行RAILS_ENV=production rake db:migrate时报下面错误
rake aborted!
Object is not missing constant Issue!
此故障为找不到mysql连接库文件,一般是在前面安装mysql的时候没有加后面参数,没有指定源码安装的mysql路径,加上路径重装安装一次mysql适配器就行了。