1.安装系统包和部分软件包
yum -y install patch make gcc gcc-c++ gcc-g77 flex* bison file
yum -y install libtool libtool-libs libtool-ltdl-devel* autoconf kernel-devel automake libmcrypt*
yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal nano sendmail
yum -y install fonts-chinese gettext gettext-devel
yum -y install gmp-devel pspell-devel
yum -y install readline* libxslt* pcre* net-snmp* gmp* libtidy*
yum -y install ImageMagick* subversion*
2.安装mysql
我刚开始用yum下载mysql,结果显示安装的是mariabdb。安装方式如下:
Step1: 检测系统是否自带安装MySQL
#yum list installed | grep mysql
Step2: 删除系统自带的mysql及其依赖 命令:
# yum -y remove mysql-libs.x86_64
Step3: 给CentOS添加rpm源,并且选择较新的源 命令:
# wget -i 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-dmr
# yum repolist enabled | grep mysql
Step4:安装mysql 服务器 命令:
# yum install mysql-community-server
Step5: 启动mysql 命令:
#service mysqld start
Step6: 查看mysql是否自启动,并且设置开启自启动 命令:
# chkconfig --list | grep mysqld
# chkconfig mysqld on
Step7: mysql安全设置 命令:
# mysql_secure_installation
默认root密码查看,以及设置密码:
grep "password" /var/log/mysqld.log
mysql
set global validate_password_policy=0;
set global validate_password_length=4;
set password for 'xxxx'@'localhost'=password('xxxx');
flush privileges;
如果忘记密码,按照如下操作:
vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存并且退出vi。
service mysqld restart
update user set authentication_string=password('xxx') where user='root';
alter user 'root'@'localhost' identified by 'xxx';
3.设置mysql的账号和密码,并创建redmine数据库
service mysqld start #启动mysql
mysql -uroot -p #首次mysql的密码为空
create database redmine character set utf8;
create user 'redmine'@'localhost' IDENTIFIED BY 'pwd'; #用户名: redmine; 密码:pwd
grant all privileges on redmine.* to 'redmine'@'localhost'; #最大权限
flush privileges;
4.安装rvm
curl -sSL https://get.rvm.io | bash -s stable
#或者
curl -L https://rvm.io | bash -s stable
或者
curl -L get.rvm.io | bash -s stable
以上命令安装可能会不成功,就换做以下方式进行:
mkdir rvm
cd rvm
# Install mpapis public key (might need `gpg2` and or `sudo`)
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Download the installer
curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer
curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer.asc
# Verify the installer signature (might need `gpg2`), and if it validates...
gpg --verify rvm-installer.asc &&
# Run the installer
bash rvm-installer stable
如果gpg –keyserver命令失败,用如下命令代替:
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
就在本目录下
vi .bashrc
添加source /etc/profile.d/rvm.sh
如果不出什么错误,RVM已经安装到系统上了,可以使用了。
5.安装ruby
rvm list known #最好不要安装2.0以下的版本
rvm install ruby-1.9.3-p551 #
gem -v #如果未显示版本,重新安装ruby
#如果安装2.0以上的版本,可能会创建账户不能编辑、项目不能创建等问题
#redmine中的log记录为ActionView::Template::Error (undefined method `name' for nil:NilClass):
如果提示版本不对,就按照如下操作:
rvm install 2.4.1
source /etc/profile.d/rvm.sh
6.如果gem的源所在的网络不好,可以更改源
gem source -l # 查看当前镜像源
gem source --remove ***
gem source -a http://ruby.taobao.org #新增gem的镜像源(确保只有ruby.taobao.org)
如果失败了尝试一下:
gem source -a https://ruby.taobao.org
7.安装rails 和 相关依赖包
gem install rails
gem install rake
gem install mysql2
如果提示rails版本不对,请按照如下操作:
gem install rails -v 4.2.2
gem install rails -v 4.2.4
gem install activesupport -v 4.2.6
gem install cocoapods
对应redmine和ruby以及rails的版本号关系如下:
所以要按照这个安装 对应的版本。
8.下载redmine并安装依赖
cd /usr/local/
svn co http://svn.redmine.org/redmine/branches/3.4-stable
mv 3.4-stable redmine
cd redmine
bundle install
9.配置redmine并初始化
cd /usr/local/redmine/
cp config/database.yml.example config/database.yml
vim config/database.yml #选择product部分修改数据库密码
rake generate_secret_token
RAILS_ENV=production rake db:migrate #生成表结构
RAILS_ENV=production rake redmine:load_default_data #初始化数据选择zh
10.启动redmine
nohup /usr/local/rvm/rubies/ruby-2.4.1/bin/ruby /usr/local/redmine/bin/rails server -e production -b 0.0.0.0 >/dev/null 2>&1 &
11.访问登录
访问 http://ip:3000/
默认账号和密码 admin admin
如果报错:Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in web_app/config/secrets.yml
复制一份存在的(vim config/initializers/secret_token.rb) 到新的redmine对应目录下面去,重启进程再试试。
以上是在centos7上实现的,同样适用于centos6.x,只是mysql那一段不需要这样特殊处理了,yum安装就可以完成,其他步骤一样的。
后续备份:
主要是备份mysql的redmine库,config下面的yml配置文件,以及files下面的附件:
#!/bin/bash
bk_time=`date +"%Y%m%d"`
cd /usr/local/redmine
tar -zcf /home/redmine/redmine_backup/conf_file_${bk_time}.tar.gz files/ config/*.yml
mysqldump -u**** -p"****" redmine |gzip > /home/redmine/mysql_backup/redmine_${bk_time}.sql.gz
以上安装过程参考这些文章列表:
http://blog.csdn.net/dzl84394/article/details/7750586
http://blog.csdn.net/mydo/article/details/47748211
https://stackoverflow.com/questions/20251429/ruby-version-error-installing-rails
http://blog.csdn.net/xjgd9900/article/details/72676571?utm_source=itdadao&utm_medium=referral