首页 > 代码库 > redmine安装部署文档

redmine安装部署文档


############################################################################## 
官网:http://www.redmine.org/ 
Redmine是一个开源的,基于Web的项目管理和缺陷跟踪工具.它用日历和甘特图辅助项目及进度可视化显示.同时它又支持多项目管理.Redmine是一个自由开放源码软件解决方案,它提供集成的项目管理功能,问题跟踪,并为多个版本控制选项的支持.虽说像IBM Rational Team Concert的商业项目调查工具已经很强大了,但想坚持一个自由和开放源码的解决方案,可能会发现Redmine是一个有用的Scrum和敏捷的选择.由于Redmine的设计受到Rrac的较大影响,所以它们的软件包有很多相似的特征。Redmine建立在Ruby on Rails的框架之上,他可以夸平台和数据库。 
############################################################################## 
redmine 用户手册: 
http://www.ossxp.com/doc/redmine/user_guide/user_guide.html 


1、ruby安装 
查找并删除系统默认的ruby软件 
rpm -qa ruby 
rpm -e --nodeps ruby 

mkdir /tools/ruby -p 
cd /tools/ruby 
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz 
tar -zxvf ruby-2.0.0-p353.tar.gz 
cd ruby-2.0.0-p353 
./configure -prefix=/usr/local/ruby 
make && make install 
cd .. 

#添加系统环境变量 
echo ‘export PATH=$PATH:/usr/local/ruby/bin‘ >>/etc/profile 
source /etc/profile 

#检验 
ruby -v 

2、更换gem源 (RubyGems的官方网站是http://www.rubygems.org/,是个包管理工具,相当于RPM、yum等工具。) 
a) gem sources -a http://ruby.taobao.org/ 
新增GEM源 
b) gem sources –remove https://rubygems.org/ 
删除自带官方源 
c) gem sources -l 
查看gem源。确保只剩下ruby.taobao.org 



3、安装bundle等依赖 
Rake的官方网站是http://rake.rubyforge.org/,可以让gem联网下载安装,也可以在官方网站下载后进行安装。 
Ruby on Rails的官方网站是http://rubyonrails.org/ 

gem install bundler 

gem install rails 

gem install rake 

gem install mysql2 
如果mysql是编译安装的,可使用 -with-mysql-config=mysql_config 的位置 

gem install mysql2 -with-mysql-config=/usr/local/mysql-5.1.68/bin/mysql_config 

4、下载redmine 
mkdir /tools/redmine -p 
cd /tools/redmine 
wget http://www.redmine.org/releases/redmine-2.4.2.tar.gz 
tar -zxvf redmine-2.4.2.tar.gz 
mv redmine-2.4.2 /usr/local/redmine 

5、#数据库上执行如下操作: 
create database redmine; 
grant all privileges on redmine.* to redmine@localhost identified by ‘redmine‘; 
flush privileges; 

cd /usr/local/redmine/config 
cp database.yml.example database.yml 

vi database.yml(前几行修改成如下内容,注意冒号后要有空格) 
######################################################## 
production: 
adapter: mysql 
database: redmine #数据库 
host: localhost #服务器IP 
username: redmine #数据库用户 
password: redmine #数据库密码 
encoding: utf8 
socket: /usr/local/mysql-5.0.92/tmp/mysql.sock 
######################################################## 


6、生成会话密钥 
cd /usr/local/redmine 
rake generate_secret_token 

若出现以下错误提示: 
------------------------------------------------------------------------------------------------------------- 
[root@test config]# rake generate_secret_token 
(in /usr/local/redmine) 
Could not find gem ‘rails (= 3.2.16) ruby‘ in the gems available on this machine. 
Run `bundle install` to install missing gems. 

[root@test config]# bundle update 

[root@test config]# rake generate_secret_token 
(in /usr/local/redmine) 
------------------------------------------------------------------------------------------------------------- 

7、rails数据库生成和数据初始化 
RAILS_ENV=production rake db:migrate 
//生成表结构 
RAILS_ENV=production REDMINE_LANG=zh rake redmine:load_default_data 
////语言环境这里配置成zh,显示在web上的 

8、启动redmine 
启动须redmine根目录下 
cd /usr/local/redmine 
nohup ruby script/rails server webrick -e production -p 8000 > /usr/local/redmine/log/webrick.log &//默认是3000 

附注:redmine默认端口的修改路径: 
/www/redmine/vendor/rails/railties/lib/commands/server.rb 

9、http://IP:8000 访问测试 
admin/admin 
修改密码 管理–用户 


10、备份还原 
Redmine的用户和问题等信息存储于Mysql数据库,表名为redmine而附件等资源存储于Redmine安装目录的files目录下.因此需要迁移的话只需要备份Mysql数据库的对应的表和files目录即可。 
备份配置文件config\*.yml 


但这样只是以独立的方式启动redmine的服务器,在后台执行,有些不足,因为客户端的访问日志会在终端上直接显示。 
并且你退出终端时,服务器进程也会跟着关闭,后面再介绍启动和关闭脚本的编写,以及如何用nginx做反向代理,或是用Apache也可以, 
这个网上可以搜索到很多资料。 


#### svn 中文乱码问题 
管理 -- 配置 -- 附件和版本库编码 --GBK 保存就可以了 
http://www.cnblogs.com/compulsive/archive/2011/08/23/2151380.html 

—————————————————————————————————————————————— 

参考:http://www.redmine.org/projects/redmine/wiki/RedmineInstall 
cd /usr/local/redmine/config 
cp configuration.yml.example configuration.yml //配置邮件 

—————————————————————————————————————————————— 
安装主题 

#到http://www.redmine.org/projects/redmine/wiki/Theme_List下载自己喜欢的主题 

ModulaMartini, ModuleMojito和pixel-cooker,推荐使用 piexl-cooker,感觉很cool 

#将zip包解压到 redmine/public/themes/ 

cd /usr/local/redmine/public/themes/ 
unzip 主题.zip //解压、 重启redmine 

#检查application.css是否在: 
#redmine/public/themes/<themename>/stylesheets/application.css 

在Web界面下设置新主题 
管理–配置–显示– 从下拉列表中选择要使用的主题,保存即可生效 

—————————————————————————————————————————————— 

安装插件 

http://www.redmine.org/plugins //插件列表 

redmine_ckeditor //编辑器 

redmine_wiki_extensions-0.6.4.zip //wiki 扩展 

redmine_agile-1_3_0-light.zip //问题列表的功能 

redmine_wiki_books-master.zip //wiki 书籍 


redmine_lightbox-master.zip // 支持 wiki 缩略图缩放 


1、下载插件,解压后,放到redmine根目录的plugins下面 
2、 Migrate plugin: 
rake redmine:plugins:migrate RAILS_ENV=production 
3、重启redmine 就可以使用了 

—————————————————————————————————————————————— 
redmine和nginx/apache整合 
默认情况下,访问redmine需要通过http://ip:port的形式来打开,为方便用户,需要用域名的方法直接打开redmine,此时就需要nginx与redmine的整合了。 

nginx与redmine的整合 

通过nginx的一个passenger模块来实现 

使用gem安装passenger 
gem install passenger 

获取passenger路径 
passenger-config about nginx-addon-dir 

重新编译nginx,添加passenger模块 


--add-module=/usr/local/ruby/lib/ruby/gems/2.0.0/gems/passenger-4.0.41/ext/nginx 


./configure --prefix=/usr/local/nginx-1.4.3 \
--add-module=/usr/local/ruby/lib/ruby/gems/2.0.0/gems/passenger-4.0.41/ext/nginx 


nginx 配置如下: 
passenger_root一定要配置 
具体可以参考这个网址:http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_installing_as_a_normal_nginx_module_without_using_the_installer

passenger_root /usr/local/ruby/lib/ruby/gems/2.0.0/gems/passenger-4.0.41; 
upstream redmine_sa { 
server 127.0.0.1:8000; 


server 

listen 80; 
server_name redmine_sa.com; 
root /usr/local/redmine/public; 

location / { 
proxy_pass http://redmine_sa; 
proxy_set_header Host $host; 
proxy_set_header X-Real_IP $remote_addr; 
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
passenger_enabled on; 





Apache反向代理 

gem install passenger 
passenger-install-apache2-module 

如果报passenger-install-apache2-module这条命令找不到的话,那么通过下面的命令查看执行路径: 
gem environment 
RubyGems Environment: 
– RUBYGEMS VERSION: 1.3.7 
– RUBY VERSION: 1.8.7 (2009-04-08 patchlevel 160) [i686-linux] 
– INSTALLATION DIRECTORY: /usr/local/ruby/lib/ruby/gems/1.8 
– RUBY EXECUTABLE: /usr/local/ruby/bin/ruby 
– EXECUTABLE DIRECTORY: /usr/local/ruby/bin 
– RUBYGEMS PLATFORMS: 
– ruby 
– x86-linux 
– GEM PATHS: 
– /usr/local/ruby/lib/ruby/gems/1.8 
– /root/.gem/ruby/1.8 
– GEM CONFIGURATION: 
– :update_sources => true 
– :verbose => true 
– :benchmark => false 
– :backtrace => false 
– :bulk_threshold => 1000 
– REMOTE SOURCES: 
– http://rubygems.org/ 
其中,EXECUTABLE DIRECTORY就是命令的全路径,所以对于我例子里的情况执行/usr/local/ruby/bin/passenger-install-apache2-module 
根据提示安装和部署。passenger会在本机编译并成为apache的一个模块。安装过程中会遇到下面的提示信息(根据版本的不同,信息也会稍有变化): 
Welcome to the Phusion Passenger Apache 2 module installer, v2.2.15. 
This installer will guide you through the entire installation process. It 
shouldn’t take more than 3 minutes in total. 
Here’s what you can expect from the installation process: 
1. The Apache 2 module will be installed for you. 
2. You’ll learn how to configure Apache. 
3. You’ll learn how to deploy a Ruby on Rails application. 
Don’t worry if anything goes wrong. This installer will advise you on how to 
solve any problems. 
The Apache 2 module was successfully installed. 
Please edit your Apache configuration file, and add these lines: 
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so 
PassengerRoot /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15 
PassengerRuby /usr/local/ruby/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: 
/usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/doc/Users guide Apache.html 
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) 
http://www.modrails.com/ 
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui. 
根据提示信息部署: 
首先,编辑apache的配置文件(/etc/httpd/conf/httpd.conf)并添加下面的信息: 
LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so 
PassengerRoot /usr/local/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.15 
PassengerRuby /usr/local/ruby/bin/ruby 

然后启用Apache的虚拟主机支持: 
1、注释掉原有的ServerName,ServerAdmin,DocumentRoot的信息; 
2、启用虚拟主机的支持,去掉NameVirtualHost *:80前面的#; 
3、在配置文件的末尾加上: 
<VirtualHost *:80> 
ServerName redmine.loosky.net 
ServerAdmin loosky@fjut.edu.cn 
DocumentRoot /var/www/redmine/public 
ErrorLog logs/redmine_error_log 
<Directory “/var/www/redmine/public”> 
Allow from all 
AllowOverride all 
</Directory> 
</VirtualHost> 
4、重启Apache服务器:service httpd restart 


——————————————————————————————————————————————————————


参考博客:

http://blog.sina.com.cn/s/blog_55a7d3ea0101ebt9.html

http://blog.csdn.net/benkaoya/article/details/8762935

http://jartai.i234.me/wordpress/?p=116

http://blog.csdn.net/wangzh1013/article/details/8558390

http://dl528888.blog.51cto.com/2382721/1217139

http://blog.csdn.net/renkai611919/article/details/7879877

http://ruby-china.org/wiki/mac-nginx-passenger-rails



redmine安装部署文档