阿汤博客-承接中小企业服务器维护和网站维护,有意者可以联系博主!

项目管理软件Readmine安装配置

运维维护 79℃ 0评论

1、安装依赖

#yum install curl-devel sqlite-devel libyaml-devel -y  

 

2、安装rvm

#curl -L https://get.rvm.io | bash -s stable  #网络问题可能失败,多执行几次

如果报错如下:

项目管理软件Readmine搭建 

执行:

#gpg2 –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

#curl -L https://get.rvm.io | bash -s stable

 

#echo "source /etc/profile.d/rvm.sh" >> /root/.bashrc

#source /etc/profile.d/rvm.sh

 

3、安装ruby

#rvm list known #查看版本

#rvm install ruby-2.5.1

#gem -v  #安装好以后查看版本

 

4、更改gem源

#gem source -l    #查看镜像源

#gem source –remove https://rubygems.org/  #删除默认源

#gem source -a https://ruby.taobao.org  #新增gem的镜像源(确保只有ruby.taobao.org)

#gem sources -a https://mirrors.aliyun.com/rubygems/ #或者添加这个

 

5、安装MySQL

a.给CentOS添加rpm源,并且选择较新的源命令:

#wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

#yum -y install mysql57-community-release-el7-7.noarch.rpm

#yum repolist all | grep mysql

#yum-config-manager –disable mysql55-community

#yum-config-manager –disable mysql56-community

#yum-config-manager –enable mysql57-community

#yum repolist enabled | grep mysql

b.安装MySQL服务器

#yum install mysql-community-server

#systemctl enable mysqld 设置开机启动

c、设置mysql的账号和密码,并创建redmine数据库

#systemctl start mysqld

#grep "password" /var/log/mysqld.log #查看默认密码

#mysql -u root -p

>set password=password('new password')

>ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; #密码永不过期

>flush privileges;

>create database redmine character set utf8; # 创建redmine数据库

>create user 'redmine'@'localhost' IDENTIFIED BY 'new password'; #设置用户redmine的密码

>grant all privileges on redmine.* to 'redmine'@'localhost';  #赋予redmine账号最大权限

> ALTER USER 'redmine'@'localhost' PASSWORD EXPIRE NEVER;#密码永不过期

>flush privileges;

 

6、安装rails和相关依赖包

#gem install rails  

#gem install rake  

#gem install mysql2  #如果报错就执行yum install mysql-devel  

 

7、安装redmine

#wget https://www.redmine.org/releases/redmine-3.4.6.tar.gz

#tar -zxvf redmine-3.4.6.tar.gz

#mv redmine-3.4.6 /usr/local/redmine

#cd /usr/local/redmine

#bundle install  #如果报错An error occurred while installing rmagick (2.16.0), and Bundler cannot continue. 执行yum install ImageMagick-devel

 

8、配置redmine并初始化

#cp config/database.yml.example config/database.yml  

#vim config/database.yml #选择product部分修改数据库密码

#rake generate_secret_token  #如果报错Could not find gem 'mysql2 (~> 0.4.6)' in any of the gem sources listed in your Gemfile. 再次执行bundle install

#RAILS_ENV=production rake db:migrate #生成表结构  

#RAILS_ENV=production rake redmine:load_default_data #初始化数据选择zh  

 

9、启动redmine

#nohup /usr/local/rvm/rubies/ruby-2.5.1/bin/ruby /usr/local/redmine/bin/rails server -e  production -b 0.0.0.0 >/dev/null 2>&1 & #nohup后台启动

#/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby /usr/local/redmine/bin/rails server -e  production -b 0.0.0.0 -d #或者-d后台启动

 

10、添加启动脚本

# vim /etc/init.d/redmined

#!/bin/bash

 

#redmine   Startup script for the redmine server

#chkconfig:  2345 85 15

 

Prog=redmine

 

#find the redmine's pid

Pid=`ps aux | grep "\<$Prog\>" | pidof ruby`

 

ProgPort=80 #默认端口3000

ReturnCode=`ss -tlnp | awk -F' ' '{print$4}' | grep "\<$ProgPort\>" &> /dev/null;echo $?`

 

start() {

        if [ $ReturnCode -eq 0 ] &> /dev/null;then

            echo " Redmine is Already Running !!! "

        else

            /usr/local/rvm/rubies/ruby-2.5.1/bin/ruby /usr/local/redmine/bin/rails server -e  production -b 0.0.0.0 -p $ProgPort -d >/dev/null

            echo -e "Starting redmine ….. \e[32m[ OK ]\e[m"

        fi

}

 

stop() {

        if [ $ReturnCode  -ne 0 ] &> /dev/null;then

            echo " Redmine is Already  Stopped !!!"     

        else

            kill  -9  $Pid

            echo -e "Stopping redmine ….. \e[32m[ OK ]\e[m"

        fi

}

 

status() {

        if [ $ReturnCode -eq 0 ] &> /dev/null;then

            echo " Redmine is Running !!! "

        else

            echo " Redmine is Stopped !!! "

        fi

}

 

case "$1"  in

    start)

        start

        ;;

    stop)

        stop

        ;;

    status)

        status

        ;;

    restart)

        stop

        start

        ;;

        *)

        echo "Usage: $Prog {start|stop|status|restart}"

Esac

#chmod +x /etc/init.d/redmined

#/etc/init.d/redmined start

#chkconfig –add redmined

 

11、访问项目

#firewall-cmd –add-port=3000/tcp –permanent –zone=public #如果是80 此处就设置80

#firewall-cmd –reload

http://192.168.133.130:3000 初始账号admin 密码admin

项目管理软件Readmine搭建 


12、备份或迁移

只需要备份(或者迁移)mysql的redmine库,config下面的yml配置文件,以及files下面的附件。

#!/bin/bash

bk_time=`date +"%Y%m%d"`

redmine_dir='/usr/local/redmine'

cd $redmine_dir

tar -zcf /root/backup_data/files/conf_file_${bk_time}.tar.gz files/ config/*.yml  &> /dev/null

mysqldump  redmine | gzip > /root/backup_data/mysql/redmine_${bk_time}.sql.gz


注意: mysql5.6以后不能在命令行直接输入密码,解决办法

#vim /root/.my.cnf

[mysqldump]

user=yourusername

password=yourpassword

host=localhost

转载请注明:阿汤博客 » 项目管理软件Readmine安装配置

喜欢 (0)or分享 (0)