版本: redmine 3.1.1
官方文档地址: http://www.redmine.org.cn/category/install
下列描述均以操作系统 Centos7 为例部署。
步骤:
OS | IP | HostName | Role |
---|---|---|---|
CentOS7 x64 | 192.168.10.10 | node1 | Redmine恢复机器 |
CentOS7 x64 | 10.10.1.17 | localhost | Redmine机器 |
# 关闭Iptables和SELinux [root@node1 ~]# systemctl stop firewalld [root@node1 ~]# systemctl disable firewalld [root@node1 ~]# setenforce 0 [root@node1 ~]# sed -i '/^SELINUX=/{ s/enforcing/disabled/ }' /etc/selinux/config # 调整服务器时间 [root@node1 ~]# yum -y install ntp [root@node1 ~]# ntpdate -u 202.120.2.101
# 安装依赖环境 [root@node1 ~]# yum install -y zlib-devel openssl-devel ImageMagick-devel wget curl-devel rubygems mod_fcgid # 安装RVM [root@node1 ~]# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 [root@node1 ~]# curl -L https://get.rvm.io | bash -s stable # 载入RVM环境并获取需要的支持安装包 [root@node1 ~]# source /etc/profile.d/rvm.sh [root@node1 ~]# rvm requirements # 利用rvm安装 Ruby 2.2.3 并设为默认 [root@node1 ~]# sed -i -E 's!https?://cache.ruby-lang.org/pub/ruby!https://ruby.taobao.org/mirrors/ruby!' /usr/local/rvm/config/db [root@node1 ~]# rvm gemset create [root@node1 ~]# rvm install 2.2.3 [root@node1 ~]# rvm use 2.2.3 --default # 添加淘宝镜像 [root@node1 ~]# gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ [root@node1 ~]# gem sources -l *** CURRENT SOURCES *** https://gems.ruby-china.org # 安装rails [root@node1 ~]# gem install rails -v=4.2 # 安装mysql和httpd [root@node1 ~]# yum install httpd httpd-devel -y [root@node1 ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [root@node1 ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [root@node1 ~]# yum -y install mysql-community-server mysql-devel [root@node1 ~]# service mysqld restart [root@node1 ~]# mysql -u root mysql> create database redmine character set utf8; mysql> create user 'redmine'@'localhost' identified by 'redmine'; mysql> grant all privileges on redmine.* to 'redmine'@'localhost'; # 安装redmine的apache支持,这样可以通过apache访问 [root@node1 ~]# gem install passenger [root@node1 ~]# passenger-install-apache2-module [root@node1 ~]# vim /etc/httpd/conf.d/passenger.conf LoadModule passenger_module /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.30/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.30 PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.2.3/wrappers/ruby </IfModule> [root@node1 ~]# vim /etc/httpd/conf.d/redmine.conf <VirtualHost *:80> ServerName www.a.com # !!! Be sure to point DocumentRoot to 'public'! DocumentRoot /var/www/html/redmine/public ErrorLog logs/redmine_error_log <Directory /var/www/html/redmine/public> Options Indexes ExecCGI FollowSymLinks Order allow,deny Allow from all # This relaxes Apache security settings. AllowOverride all # MultiViews must be turned off. Options -MultiViews # Uncomment this if you're on Apache >= 2.4: #Require all granted </Directory> </VirtualHost>
# 安装redmine [root@node1 ~]# cd /var/www/html [root@node1 ~]# wget http://www.redmine.org/releases/redmine-3.1.1.tar.gz [root@node1 ~]# tar -zxvf redmine-3.1.1.tar.gz [root@node1 ~]# mv redmine-3.1.1 redmine [root@node1 ~]# cd /var/www/html/redmine/ [root@node1 ~]# vim Gemfile # 修改source #source 'https://rubygems.org' source'https://ruby.taobao.org' [root@node1 ~]# cp config/configuration.yml.example config/configuration.yml [root@node1 ~]# cp config/database.yml.example config/database.yml [root@node1 ~]# vim config/database.yml # 修改数据连接 production: adapter: mysql2 database: redmine host: localhost username: redmine password: "redmine" encoding: utf8 [root@node1 redmine]# gem install bundler # 注意是在网站根目录下执行 [root@node1 redmine]# gem install rack-cache -v '1.4.2' [root@node1 redmine]# bundle install # 为Rails生成cookies密钥 [root@node1 redmine]# rake generate_secret_token # 初始化redmine数据库表名 [root@node1 redmine]# RAILS_ENV=production rake db:migrate [root@node1 redmine]# RAILS_ENV=production rake redmine:load_default_data # 启动 [root@node1 ~]# cd /var/www/html/redmine [root@node1 redmine]# mkdir /var/www/html/logs [root@node1 redmine]# bundle exec rails server webrick -e production -b 0.0.0.0 &>> /var/www/html/logs/redmine.log &
访问地址:http://IP:3000
[root@node1 ~]# mysqldump -u root redmine > /root/redmine.sql
# 停止redmine, 步骤:ps -ef | grep rails,找到redmine的进程号,然后kill掉 # 恢复数据库 [root@node1 ~]# mysql -u redmine -p redmine < /root/redmine.sql # 把10.10.2.120上的/backup/redmine-back/redmine_file目录下的所有文件拷贝到192.168.100.10中的/var/www/html/redmine/files目录 [root@node1 ~]# scp -r root@10.10.2.120:/backup/redmine-back/redmine_file/* /var/www/html/redmine/files [root@node1 ~]# chmod -R 755 /var/www/html/redmine/files # 启动redmine [root@node1 redmine]# bundle exec rails server webrick -e production -b 0.0.0.0 &>> /var/www/html/logs/redmine.log &
# 配置邮件发送,空格缩进必须如下,不然redmine无法启动 [root@node1 ~]# vim /var/www/html/redmine/config/configuration.yml default: email_delivery: delivery_method: :smtp smtp_settings: openssl_verify_mode: 'none' address: mail.testin.cn port: 587 domain: testin.cn authentication: :login user_name: "project@testin.cn" password: "m12345678" # 重启redmine即可