Howto Install Redmine on Ubuntu 16.04

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# base
apt install mysql-server libmysqlclient-dev git-core subversion imagemagick libmagickwand-dev libcurl4-openssl-dev
apt install build-essential mysql-server ruby ruby-dev libmysqlclient-dev imagemagick libmagickwand-dev
# install mysql
systemctl enable mysql.service
systemctl start mysql.service
create database redmine character set utf8;
grant all privileges on redmine.* to redmine@'localhost' identified by 'redmine';
flush privileges;
# Install ruby
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements
rvm install 2.4.1
rvm use 2.4.1 --default
# install passenger and nginx
gem install passenger --no-ri --no-rdoc
passenger-install-nginx-module
# 1. auto install nginx.
curl https://raw.githubusercontent.com/makevoid/nginx-passenger-ubuntu/master/nginx/nginx.service > /lib/systemd/system/nginx.service
systemctl daemon-reload
systemctl enable nginx
vim /opt/nginx/conf/nginx.conf # 注销 location / {} 的配置
server {
listen 80;
server_name [your_server_domain_name] # redmine.com;
root /var/data/redmine/public;
passenger_enabled on;
client_max_body_size 10m; # Max attachemnt size
}

systemctl start nginx
# install redmine
mkdir /var/data
cd /var/data
svn co http://svn.redmine.org/redmine/branches/3.4-stable redmine
cd /var/data/redmine
cp -pR /var/data/redmine/config/database.yml.example /var/data/redmine/config/database.yml
vim config/database.yml # set redmine db user and password
# Install Plugins
cd /var/data/redmine
gem install bundler --no-ri --no-rdoc
bundle install
# configure redmine
cd /var/data/redmine
mkdir public/plugin_assets
chown -R www-data:www-data files log tmp public/plugin_assets config.ru
chmod -R 755 files log tmp public/plugin_assets
# input database and base file.
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data
bundle exec rake generate_secret_token
# restart nginx, install ok.
systemctl restart nginx
# restart redmine
touch /var/data/redmine/tmp/restart.txt
# configure email service
vim /var/data/redmine/config/configuration.yml

HowTo Install Redmine

Runtime environment

  • CentOS 6.x
  • Redmine 3.3.2
  • Ruby 2.2.6
  • rails 4.2
  • MySQL 5.1
  • Nginx 1.10

安装rvm

导入公钥
1
[root@localhost ~]# curl -sSL https://rvm.io/mpapis.asc | gpg --import
安装
1
[root@localhost ~]# curl -L https://get.rvm.io | bash -s stable
加载rvm环境并安装基础依赖包
1
2
[root@localhost ~]# source /etc/profile.d/rvm.sh
[root@localhost ~]# rvm requirements

安装ruby

1
2
3
[root@localhost ~]# rvm install 2.2.6
...
[root@localhost ~]# rvm use 2.2.6 --default

安装rails

更换gem源

默认gem的源站点是https://rubygems.org 由于国内的网络原因导致无法连接,所以导致无法使用gem安装,这里换成国内淘宝的gem镜像站点

1
2
3
4
5
6
7
8
9
10
[root@localhost ~]# gem sources -l
*** CURRENT SOURCES ***

https://rubygems.org/
[root@localhost ~]# gem sources --remove https://rubygems.org/
[root@localhost ~]# gem sources -a https://ruby.taobao.org/
[root@localhost ~]# gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/
安装
1
[root@localhost ~]# gem install rails -v=4.2

安装MySQL

1
2
3
[root@localhost ~]# yum install -y mysql-server mysql-libs mysql-devel mysql
[root@localhost ~]# service mysqld start
[root@localhost ~]# mysql_secure_installation

安装redmine

下载Redmine 3.3.2
1
2
3
[root@localhost ~]# wget http://www.redmine.org/releases/redmine-3.3.2.tar.gz
[root@localhost ~]# tar xf redmine-3.3.2.tar.gz
[root@localhost ~]# mv redmine-3.3.2 /opt
安装管理ruby的包管理工具bundler
1
2
3
# 注意,一定要在redmine目录下操作
[root@localhost ~]# cd /opt/redmine-3.3.2
[root@localhost redmine-3.3.2]# gem install bundler
安装redmine运行所需要的依赖包
1
[root@localhost redmine-3.3.2]# bundle install --without development test rmagick
为rails生产cookies秘钥
1
[root@localhost redmine-3.3.2]# rake generate_secret_token
创建redmine的数据库
1
2
mysql> create database redmine character set utf8;
mysql> grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'redmine_pass';
修改redmine的database.yml
1
2
3
4
5
6
7
8
9
[root@localhost redmine-3.3.2]# cp config/database.yml.example config/database.yml
[root@localhost redmine-3.3.2]# vim config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "redmine_pass"
encoding: utf8
创建数据库结构
1
[root@localhost redmine-3.3.2]# RAILS_ENV=production bundle exec rake db:migrate
生产缺省数据
1
2
[root@localhost redmine-3.3.2]# RAILS_ENV=production bundle exec rake redmine:load_default_data
# 选择默认语言,之后可更改,初始为en
测试是否安装成功
1
[root@localhost redmine-3.3.2]# bundle exec rails server webrick -e production -b 0.0.0.0

默认运行3000端口,默认管理员admin/admin

配置Redmine在Nginx上运行

Redmine常用的解决办法是使用passenger+nginx,但是Nginx不支持装载模块,所以需要重新编译安装Nginx,安装Nginx的Passenger有两种方式

  • 采用Passenger提供的脚本进行安装,适合新环境
  • 手动编译安装Nginx增加Passenger模块,适合已存在Nginx环境
采用Passenger提供脚本安装
1
2
[root@localhost redmine-3.3.2]# gem install passenger
[root@localhost redmine-3.3.2]# passenger-install-nginx-module --auto --prefix=/opt/nginx
采用重新编译Nginx增加Passenger模块
1
2
3
4
5
6
7
8
9
# 获取passenger的安装路径
[root@localhost ~]# passenger-config --root
/usr/local/rvm/gems/ruby-2.2.6/gems/passenger-5.1.2

# 重新编译Nginx并添加模块
[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz
[root@localhost ~]# tar xf nginx-1.10.3.tar.gz
[root@localhost ~]# cd nginx-1.10.3
[root@localhost nginx-1.10.3]# ./configure ... -add-module=/usr/local/rvm/gems/ruby-2.2.6/gems/passenger-5.1.2
增加HTTP模块内以下配置
1
passenger_root /usr/local/rvm/gems/ruby-2.2.6/gems/passenger-5.1.2
配置nginx.conf 修改server模块中location的配置
1
2
3
4
5
6
7
8
9
10
# ...
server {
# ...
passenger_enabled on;
location / {
root /opt/redmine-3.3.2/public;
index index.html index.htm;
}
}
# ...
启动Nginx
1
[root@localhost ~]# /root/nginx-1.10.3/sbin/nginx -c /root/nginx-1.10.3/conf/nginx.conf

其他

到这里,所有的安装都完成了,过程中我遇到这些问题,你也注意下:

7.1 Could not find gem ‘mysql2 (~> 0.3.11)’ in any of the gem sources listed in your Gemfile.
1
2
[root@localhost redmine-3.3.2]# rm -f Gemfile.lock
[root@localhost redmine-3.3.2]# bundle install
7.2 curl-tools
1
yum install libcurl-devel
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×