环境:Centos 6.4
Redmine 3.0.5
安装前请关闭Selinux与iptables
== Requirements==
* Ruby >= 1.9.3
* RubyGems
* Bundler >= 1.5.0
* A database:
* MySQL (tested with MySQL 5.1)
* PostgreSQL (tested with PostgreSQL 9.1)
* SQLite3 (tested with SQLite 3.7)
* SQLServer (tested with SQLServer 2012)
Setup 1:Environment installation
安装redmine所需要的环境包:
[root@CentOS software]# yum -y install libyaml libyaml-devel zlib zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel gcc ruby-devel gcc-c++ make postgresql-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA rubygems
安装PHP环境:
[root@CentOS software]# yum -y install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap
安装redmine password要求的环境包:
[root@Centos ~]# yum -y install readline-devel libffi-devel
Setup 2:Create an empty database and accompanying user:
[root@Centos ~]# useradd -s /sbin/nologin redmine [root@Centos ~]# mysql -uroot -predhat mysql> create database redmine default character set utf8 collate utf8_general_ci; mysql> create user 'redmineuser'@'172.24.17.120' identified by 'redminepass'; mysql> grant all privileges on redmine.* to 'redmineuser'@'172.24.17.120'; mysql> grant all privileges on redmine.* to 'redmineuser'@'localhost'; mysql> flush privileges; mysql> commit;
Setup 3:Database connection configuration:
[root@redmine software]# tar -zxvf redmine-3.0.5.tar.gz -C /usr/local/ [root@redmine software]# chown redmine:redmine /usr/local/redmine-3.0.5/ -R [root@redmine software]# cd /usr/local/redmine-3.0.5/config [root@Centos config]# cp database.yml.example database.yml [root@Centos config]# head -n 12 database.yml|tail -n 8 production: adapter: mysql2 database: redmine host: 172.24.17.120 # port: 3306 username: redmineuser password: "redminepass" encoding: utf8 [root@Centos config]#
Setup 4:Dependencies installation
[root@Centos ~]# curl -L https://get.rvm.io | bash ···· * To start using RVM you need to run `source /etc/profile.d/rvm.sh` ···· [root@Centos ~]# source /etc/profile.d/rvm.sh [root@Centos ~]# rvm list known # MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p647] [ruby-]2.1[.7] [ruby-]2.2[.3] [ruby-]2.2-head ruby-head ···· [root@Centos ~]# rvm install 1.9.3 //安装Redmine 3.0.5需要安装大于1.9.3的ruby版本 [root@Centos ~]# ruby -v ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux] [root@Centos ~]#
使用国内的gem源:
[root@Centos ~]# gem sources -l *** CURRENT SOURCES *** https://rubygems.org/ [root@Centos ~]# gem sources --remove https://rubygems.org/ https://rubygems.org/ removed from sources [root@Centos ~]# gem sources -a https://ruby.taobao.org/ https://ruby.taobao.org/ added to sources [root@Centos ~]# gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org/ [root@Centos ~]#
安装Bundler >= 1.5.0的版本:
[root@Centos ~]# gem install bundler //只有安装了ruby才能使用gem命令 Fetching: bundler-1.10.6.gem (100%) Successfully installed bundler-1.10.6 Installing ri documentation for bundler-1.10.6 1 gem installed [root@Centos ~]#
安装所需要的依赖包(建议使用国内源,否则会出现一直卡顿的现象):
[root@Centos ~]# cd /usr/local/redmine-3.0.5/ [root@Centos redmine-3.0.5]# head -1 Gemfile source 'https://ruby.taobao.org/' [root@Centos redmine-3.0.5]# [root@Centos redmine-3.0.5]# gem install rdoc-data [root@Centos redmine-3.0.5]# rdoc-data --install
看是否安装了mysql2:(因为database.yml里面定义的是mysql2)
[root@Centos redmine-3.0.5]# gem list|grep mysql2 mysql2 (0.3.20) [root@Centos redmine-3.0.5]#
安装rmagick可以处理PDF和PNG导出的图片(可选安装):
[root@Centos redmine-3.0.5]# yum -y install ImageMagick* rubygems* ruby-RMagick* [root@Centos redmine-3.0.5]# gem install rmagick [root@Centos redmine-3.0.5]# bundle install -V [root@redmine redmine-3.0.5]# rails -v Rails 4.2.3 [root@redmine redmine-3.0.5]#
Setup 4:Session store secret generation
生成使用Rails编码存储会话数据,从而防止cookies随机密钥
[root@Centos redmine-3.0.5]# bundle exec rake generate_secret_token Setup 5: Database schema objects creation [root@Centos redmine-3.0.5]# RAILS_ENV=production bundle exec rake db:migrate Setup 6:Database default data set [root@Centos redmine-3.0.5]# RAILS_ENV=production bundle exec rake redmine:load_default_data Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] zh ==================================== Default configuration data loaded. [root@Centos redmine-3.0.5]#
修改fastcgi:
[root@Centos ~]# cd /usr/local/redmine-3.0.5/public/ [root@Centos public]# mkdir plugin_assets //如果没有就创建 [root@Centos public]# cp dispatch.fcgi.example dispatch.fcgi [root@Centos public]# cp htaccess.fcgi.example .htaccess Setup 7:File system permissions [root@Centos redmine-3.0.5]# chown -R redmine:redmine * [root@Centos redmine-3.0.5]# chmod -R 755 files log tmp public/plugin_assets Setup 8:Test the installation [root@Centos redmine-3.0.5]# bundle exec rails server -b 172.24.17.120 webrick -e production -d => Booting WEBrick => Rails 4.2.3 application starting in production on http://172.24.17.120:3000 => Run `rails server -h` for more startup options [root@Centos redmine-3.0.5]#
注:使用bundle exec rails server -b 172.24.17.120 webrick -e production -d和ruby bin/rails server -b 172.24.17.120 webrick -e production -d均可启动Redmine
[root@Centos redmine-3.0.5]# netstat -tunlp |grep 3000 tcp 0 0 172.24.17.120:3000 0.0.0.0:* LISTEN 82098/ruby [root@Centos redmine-3.0.5]# ps -ef |grep ruby |grep -v grep root 82098 1 0 15:16 ? 00:00:00 /usr/local/rvm/rubies/ruby-1.9.3-p551/bin/ruby bin/rails server -b 172.24.17.120 webrick -e production -d [root@Centos redmine-3.0.5]# [root@Centos redmine-3.0.5]# kill -9 82098 //结束Redmine进程
Setup 9:Installation Nginx(可忽略):
[root@Centos ~]# yum erase nginx [root@Centos ~]# gem install passenger -V [root@Centos ~]# gem -v /--version 2.4.8s [root@Centos software]# tar -zxvf nginx-1.7.11.tar.gz [root@Centos ~]# useradd -s /sbin/nologin nginx [root@Centos software]# passenger-install-nginx-module
[root@Centos ~]# chown nginx:nginx /usr/local/nginx/ -R [root@Centos ~]# head -1 /usr/local/nginx/conf/nginx.conf user nginx nginx; [root@Centos ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf [root@Centos ~]# netstat -tunlp|grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 54828/nginx [root@Centos ~]#
访问下:
Setup 10:Backups Redmine backups should include: data (stored in your redmine database) p_w_uploads (stored in the files directory of your Redmine install) [root@Centos ~]# sh redmine_backup.sh [root@Centos ~]# ls /usr/local/backup/ files redmine_15_11_17.gz [root@Centos ~]# ls /usr/local/backup/files/ redmine-3.0.5 [root@Centos ~]#
[root@Centos ~]# chkconfig --add redmined [root@Centos ~]# chkconfig redmined on
如果重启服务器,报下面的错误:
解决办法:
[root@Centos ~]# echo 'rvm_silence_path_mismatch_check_flag=1' >> ~/.rvmrc
如果再重启服务器,报下面的错误:
解决办法:
[root@Centos ~]# gem install rake [root@Centos ~]# gem install ruby-mysql [root@Centos ~]# gem install mysql [root@Centos ~]# bundle install --deployment -V [root@Centos ~]# netstat -tunlp|grep 3000 tcp 0 0 172.24.17.120:3000 0.0.0.0:* LISTEN 1632/ruby [root@Centos ~]#
注:常用的源
http://rubygems.org/
http://gems.github.com
http://gems.rubyforge.org
https://ruby.taobao.org //国内的这个比较靠谱,适合安装大多数gem
http://ruby.sdutlinux.org/ //山东大学的ruby gem镜像源
进入 Administration-Settings 报 HTTP 500 错误:
解决方法:
查看 redmine 的 tmp/cache 目录,查看目录结构应该如下所示:
[root@Centos redmine-3.0.5]# tree tmp/cache tmp/cache └── 900 └── 0F0 └── i18n%2Flanguages_options
停止 redmine,然后删除 tmp/cache 目录下的所有文件,再启动 redmine
然后 管理员设置界面 Administration-Settings 就可以进入了。
这时查看 tmp/cache 目录结构,会发现先前删除的文件和文件夹自动被创建了。
转载于:https://blog.51cto.com/yfshare/1719059