部署环境
CentOS release 6.x (Final)
redmine-3.4.6.tar.gz
http://www.redmine.org/projects/redmine/wiki/RedmineInstall //安装说明

redmine 3.4.6
ruby 2.2.4
rails 4.2
mysql 5.7

Redmine version Supported Ruby versions Rails version used
4.0 (upcoming) ruby 2.2(2.2.2 and later), 2.3, 2.41 Rails 5.1
3.4 ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3, 2.41 Rails 4.2
3.3 ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3 Rails 4.2
3.2 ruby 1.9.34, 2.0.03, 2.1, 2.22 Rails 4.2

1、rvm安装

增加并且换ruby用户

useradd ruby
su ruby

导入秘钥

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

安装rvm

curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
source ~/.bashrc
source ~/.bash_profile

修改国内源ruby下载

echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db

安装依赖(sudo或者root用户)

sudo yum install -y patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel openssl-devel

安装ruby编译库

rvm requirements

2、安装ruby

查看版本

rvm list known

二进制安装

rvm install 2.2.4

如果遇见下面的错误
Libraries missing for ruby-2.2.4: libyaml-0.so.2. Refer to your system manual for installing libraries
请到
https://rpmfind.net/linux/rpm2html/search.php?query=libyaml-0.so.2()(64bit)
找到对应的版本安装,这里用到的是

wget https://rpmfind.net/linux/centos/6.10/os/x86_64/Packages/libyaml-0.1.3-4.el6_6.x86_64.rpm
sudo rpm -ivh libyaml-0.1.3-4.el6_6.x86_64.rpm

或者源码编译安装

rvm install 2.2.4 --disable-binary

设置ruby默认版本

rvm use 2.2.4 --default

【注意】如果报错
bash: bundle: command not found
则再次执行

source ~/.rvm/scripts/rvm

3、安装rails

修改gem源-国内的

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

https://gems.ruby-china.com/ added to sources
https://rubygems.org/ removed from sources

查看源是否替换成功,请确保只有gems.ruby-china.com

gem sources -l

CURRENT SOURCES
https://gems.ruby-china.com

安装rails 4.2,显示过程-V 安装过程5分钟左右

gem install rails -v=4.2 -V

Bundler的Gem国内源

bundle config mirror.https://rubygems.org https://gems.ruby-china.com

4、安装redmine

cd /usr/local/src
sudo wget http://www.redmine.org/releases/redmine-3.4.6.tar.gz
sudo tar -zxf redmine-3.4.6.tar.gz
sudo chown -R ruby:ruby redmine-3.4.6
cd redmine-3.4.6

在redmine根目录执行依赖gem安装

gem install bundler

安装redmine依赖的所有ruby包

sudo yum install -y ImageMagick ImageMagick-devel
bundle install --without development test rmagick

5、安装MySQL

MySQL5.7安装过程见《CentOS安装MySQL5.7》一定要记得安装mysql-community-devel
安装gem mysql2

gem install mysql2 -v=0.4.6

配置Redmine的database.yml,并创建对应的数据库

cp config/database.yml.example config/database.yml
vi config/database.yml
production:
    adapter: mysql2
    database: redmine
    host: 127.0.0.1 // localhost是本地sock连接的,ip是通过tcp/ip连接
    username: www
    password: "dbpwd123"
    encoding: utf8

生成cookies秘钥

bundle exec rake generate_secret_token

在mysql数据库创建redmine库,请手动去数据库创建,之后才能继续执行下面的操作

创建数据库结构

RAILS_ENV=production bundle exec rake db:migrate

生成缺省数据语言

RAILS_ENV=production bundle exec rake redmine:load_default_data

6、测试redmine

在WEBrick服务上测试Redmine是否安装成功

bundle exec rails server webrick -e production -b 0.0.0.0

【注意】如果报错
bash: bundle: command not found
则再次执行

source ~/.rvm/scripts/rvm

【注意】打开iptables 3000端口
http://ip:3000

缺省管理员用户
admin:admin

7、redmine运行在nginx(这步之后就不能使用yum安装在/etc/nginx了,也就是不能使用service nginx start/stop/restart/reload命令,因为是新安装的另一个nginx了)

安装passenger

gem install passenger

【注意】如果报错
bash: gem: command not found
则再次执行

rvm use 2.2.4 --default

创建编译安装nginx的目录

sudo mkdir /opt/nginx
sudo chown ruby:ruby /opt/nginx

安装模块(直接重新编译)

passenger-install-nginx-module

【如果报错】
c++: Internal error: Killed (program cc1plus)

image.png

则代表内存不够,如果内存小可以尝试调大交换区大小,我的500M没够提示的这个,调整到900M后顺利通过,操作方法见《CentOS删除/添加交换分区》

正确安装后显示这个样子

image.png

安装完毕nginx后在/opt/nginx/conf/nginx.conf中增加两个配置,如下

http {
    ...
    passenger_root /home/ruby/.rvm/gems/ruby-2.2.4/gems/passenger-5.3.4;
    passenger_ruby /home/ruby/.rvm/gems/ruby-2.2.4/wrappers/ruby;
    ...
}

将项目移动到web目录下

mv /usr/local/src/redmine-3.4.6 /var/www/html/redmine

创建/opt/nginx/conf.d/redmine.regskynet.com.conf(当然了,需要在/opt/nginx/conf/nginx.conf的http中增加包含 include /opt/nginx/conf.d/*.conf; ),内容如下

server {
    listen 80;
    server_name redmine.regskynet.com;
    index index.html index.htm;
    root /var/www/html/redmine-3.4.6/public;
    passenger_enabled on;
}

重启nginx

ps axu|grep nginx
kill -9 进程号1 进程号2 进程号...
/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf

如果嫌弃这样麻烦可以参考这个文章 《Linux源码编译nginx使用service启动的方法》 ,把nginx操作改为service操作

安装后的样子 RedMine实例网址

【注意】
1024以下端口需要root 权限才能启动,必须以root 权限启动nginx

邮件异步

  1. 进入redmine目录下的config目录;
  2. 编辑configuration.yml;
  3. 找到 delivery_method: :smtp,将smtp改为async_smtp,保存退出;
  4. 重启nginx服务;
Last modification:November 30th, 2019 at 11:55 am