redmine3.2 的部署

时间:2021-06-26 18:24:07

安装libyaml

[root@ ~]#wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz -O /dist/dist/yaml-0.1.4.tar.gz
[root@ ~]#cd /dist/src/
[root@ ~]#tar zxf /dist/dist/yaml-0.1.4.tar.gz
[root@ ~]#cd yaml-0.1.4
[root@ yaml-0.1.4]#./configure
[root@ yaml-0.1.4]#make
[root@ yaml-0.1.4]#make install

安装 rvm

[root@ ~]#curl -#LO https://rvm.io/mpapis.asc
[root@ ~]#gpg --import mpapis.asc
[root@ ~]#curl -L get.rvm.io | bash -s stable
[root@ ~]#source /etc/profile.d/rvm.sh

rvm使用的简要说明

列出已知的 Ruby 版本

rvm list known

安装一个 Ruby 版本

rvm install 2.2.0 --disable-binary
这里安装了最新的 2.2.0, rvm list known 列表里面的都可以拿来安装。

切换 Ruby 版本

rvm use 2.2.0

设置为默认版本,这样一来以后新打开的控制台默认的 Ruby 就是这个版本

rvm use 2.2.0 --default

查询已经安装的ruby

rvm list

卸载一个已安装版本

rvm remove 1.8.7

在 rvm 控制下ruby版本的情况下,由 rubygem 安装的各种软件(例如:rails),统一在 /usr/local/rvm/gems/ruby-${version}/gems/目录下,由 rvm 命令统一调度。

gem 命令在 rvm install ${ruby version} 安装ruby时,就已经安装了:/usr/local/rvm/rubies/ruby-${version}/bin/gem

至于2.4.x版本的ruby,请先忽略它。


rvm 安装ruby2.2

ruby 错误

ossl_pkey_ec.c:816: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)
ossl_pkey_ec.c:816: error: (Each undeclared identifier is reported only once
ossl_pkey_ec.c:816: error: for each function it appears in.)
make[2]: *** [ossl_pkey_ec.o] Error 1
make[2]: Leaving directory `/dist/src/ruby-1.9.3-p448/ext/openssl'
make[1]: *** [ext/openssl/all] Error 2
make[1]: Leaving directory `/dist/src/ruby-1.9.3-p448'
make: *** [build-ext] Error 2

centos新版本默认openssl的配置变更取消了对EC_xx的支持,取消编译安装ruby,使用rvm

[root@ ~]#rvm install 2.2.0 --disable-binary  # 安装2.2.0 版本的ruby
[root@ ~]#rvm use 2.2.0
Using /usr/local/rvm/gems/ruby-2.2.0
[root@ ~]#rvm list rvm rubies * ruby-1.9.3-p448 [ x86_64 ]
=> ruby-2.2.0 [ x86_64 ] # => - current
# =* - current && default
# * - default [root@ ~]#ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
[root@ ~]#rvm use 2.2.0 --default

Gems 源

taobao Gems 源已停止维护,现由 ruby-china 提供镜像服务

[root@ ~]# gem sources -a http://gems.ruby-china.org
http://gems.ruby-china.org added to sources
[root@ rubygems-2.1.7]# gem sources -l
*** CURRENT SOURCES *** http://gems.ruby-china.org

安装 rails 4.2

[root@ ~]# gem install rails -v=4.2
[root@ ~]# rails -v
Rails 4.2.0
[root@ ~]#

安装mysql模块

[root@ ~]# gem install mysql2

安装bundle

[root@ ~]# gem install bundler

安装Passenger

准备nginx编译环境

[root@ ~]#yum install gcc openssl-devel pcre-devel zlib-devel
[root@ ~]#wget http://pkgs.fedoraproject.org/repo/pkgs/gperftools/gperftools-2.0.tar.gz/13f6e8961bc6a26749783137995786b6/gperftools-2.0.tar.gz -O /dist/dist/gperftools-2.0.tar.gz
[root@ ~]# cd /dist/src/
[root@ src]# tar xf /dist/dist/gperftools-2.0.tar.gz
[root@ src]# cd gperftools-2.0/
[root@ gperftools-2.0]# ./configure
[root@ gperftools-2.0]# make
[root@ gperftools-2.0]# make install
[root@ gperftools-2.0]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
[root@ gperftools-2.0]# /sbin/ldconfig

安装passenger+编译nginx

[root@ ~]# gem  install  passenger
[root@ ~]# passenger-install-nginx-module
### 一些输出信息,提示如何安装 ###
Press Enter to continue, or Ctrl-C to abort.
# 回车继续
Which languages are you interested in?
# 要求选择语言
Use <space> to select.
If the menu doesn't display correctly, press '!' ‣ ⬡ Ruby
⬢ Python
⬢ Node.js
⬡ Meteor Do you want this installer to download, compile and install Nginx for you?
# 选择安装方式
1. Yes: download, compile and install Nginx for me. (recommended) The easiest way to get started.
A stock Nginx 1.10.2 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice. 2. No: I want to customize my Nginx installation. (for advanced users) Choose this if you want to
compile Nginx with more third party modules besides Passenger, or if you need to pass additional
options to Nginx's 'configure' script. This installer will 1) ask you for the location of the Nginx source code, 2) run the 'configure' script according to your instructions, and 3) run 'make install'. Whichever you choose, if you already have an existing Nginx configuration file,then it will be preserved. Enter your choice (1 or 2) or press Ctrl-C to abort: 2 -------------------------------------------- Where is your Nginx source code located? Please specify the directory: /dist/src/nginx-1.10.2
# 源码包路径
-------------------------------------------- Where do you want to install Nginx to? Please specify a prefix directory [/opt/nginx]: /usr/local/nginx
# 安装路径 Extra Nginx configure options Extra arguments to pass to configure script: --user=www --group=www --with-http_flv_module --with-google_perftools_module
# 编译选项 Nginx with Passenger support was successfully installed.
# 完成

编辑nginx的配置文件

http {
...
passenger_root /usr/local/rvm/gems/ruby-2.2.0/gems/passenger-5.1.2;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.0/wrappers/ruby;
passenger_user www;
passenger_group www;
...
}

安装配置 redmine 3.2

安装 redmine

[root@ web]# cd /data/web/
[root@ web]# svn co https://svn.redmine.org/redmine/branches/3.2-stable redmine-3.2
[root@ web]# cd redmine-3.2/
[root@ redmine-3.2]# bundle install --without development test postgresql sqlite rmagick

配置数据库

mysql> create database redmine  character set utf8;
mysql> create user 'redmineuser'@'localhost' identified by 'na4#Z**c';
mysql> grant all privileges on `redmine_%`.* to 'redmineuser'@'localhost' ;
mysql> flush privileges; [root@ redmine-3.2]#vi config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmineuser
password: "na4#Z**"
encoding: utf8

生成数据库和admin用户

 # 生成秘钥
[root@ redmine-3.2]# rake generate_secret_token
# 初始化数据库
[root@ redmine-3.2]# RAILS_ENV="production" rake db:migrate
# 导入默认数据
[root@ redmine-3.2]# RAILS_ENV=production REDMINE_LANG=zh bundle exec rake redmine:load_default_data

配置nginx站点

[root@ redmine-3.2]# vim /data/conf/nginx/vhost/redmine.conf
server {
listen 80;
server_name redmine.test.com;
root /data/web/redmine-3.2/public;
passenger_enabled on;
access_log /data/logs/redmine.test.com.log main;
}

安装 knowledgebase插件

[root@ ~]# wget https://github.com/alexbevi/redmine_knowledgebase/archive/v3.2.0.tar.gz
[root@ ~]# mv v3.2.0 v3.2.0.tar.gz
[root@ ~]# tar xf v3.2.0.tar.gz
[root@ ~]# cp redmine_knowledgebase-3.2.0/ /data/web/redmine-3.2/plugins/redmine_knowledgebase -r
[root@ ~]# cd data/web/redmine-3.2
[root@ redmine-3.2]# bundle install --without development test postgresql sqlite rmagick
[root@ redmine-3.2]# RAILS_ENV="production" rake redmine:plugins:migrate NAME=redmine_knowledgebase

后台修改admin密码

默认管理员:admin ,密码:admin

[root@ ~]# cd /data/web/redmine-3.2/bin
[root@ bin]# ./rails console production
Loading production environment (Rails 4.2.7.1)
2.2.0 :001 > admin_user = User.find_by_login('admin')
=> #<User id: 1, login: "admin", hashed_password: "6ded810822e4e5ac56b1106dff4ce8ad582865f1", firstname: "Redmine", lastname: "Admin", admin: true, status: 1, last_login_on: nil, language: "", auth_source_id: nil, created_on: "2017-07-24 08:00:57", updated_on: "2017-07-24 08:00:57", type: "User", identity_url: nil, mail_notification: "all", salt: "478ff0cc9c4e8cc967239b5523121fcd", must_change_passwd: false, passwd_changed_on: nil>
2.2.0 :002 > admin_user.password = 'XXXX'
=> "wsjin2039"
2.2.0 :003 > admin_user.save
=> true
2.2.0 :006 > quit

FAQ

问题1:

[root@ ~]# passenger-status
/usr/local/rvm/gems/ruby-2.2.0/gems/bundler-1.14.5/lib/bundler/rubygems_ext.rb:45:in
`full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)

解决方式:

//升级gem
[root@ ~]# gem update --system

问题2:

/usr/local/rvm/gems/ruby-2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"

解决方式:

将/usr/local/rvm/gems/ruby-2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb
中的inodot重复变量注释掉一个