redmine使用源码部署(windows)

本文主要介绍在windows下使用源码方式部署安装redmine。
参考文档:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
基于redmine源码包中的INSTALL文件。

如果只是使用redmine并不需要二次开发,可以选择 Bitnami Redmine 一键安装方式,比较方便快捷,下载地址:https://bitnami.com/stack/redmine,安装过程中需要配置一下登录用户名密码,端口之类的。
由于我是需要二次开发,所以使用源码安装方式。


一、预装软件

1.ruby、RubyGems

这两个是一起安装的,直接下载exe安装包安装,下载地址:https://rubyinstaller.org/downloads/

注意:我一开始安装的是2.5版本,但是后来安装过程中有一个软件需要ruby版本小于2.4,然后我又卸载重装的2.3版本。

测试:

ruby -v 
gem -v

2.Bundler >= 1.5.0

gem install bundle

3.mysql

之前装过了。


二、新建数据库

Create an empty utf8 encoded database: “redmine” for example。

CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'your username'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

注意:这里第一句创建了一个数据库redmine,第二句和第三句分别创建了一用户并为该用户配置权限。这里不能创建root用户。


三、数据库配置

Configure the database parameters in config/database.yml。
在redmine的源码中新建config/database.yml(可参考config/database.yml.example),内容为:


production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: your username
  password: "your password"
  encoding: utf8

注意:这里的用户名和密码使用你在上一步中创建的用户名和密码。


四、安装依赖

Install the required gems by running:

bundle install --without development test

1.安装过程中报错:

redmine使用源码部署(windows)_第1张图片

解决办法:rubu版本太高,卸载2.5重新安装2.3。

2.继续报错:

ERROR:  Error installing redcarpet:
        The 'redcarpet' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

redmine使用源码部署(windows)_第2张图片

解决办法:需要构建工具DevKit并添加到path中。去https://rubyinstaller.org/downloads/ 中下载DevKit(页面中下方)安装。继续执行命令发现仍然报错。
执行DevKit安装目录下的devkitvars.bat文件把路径添加到系统变量path中。

继续报错:

Fetching rmagick 2.16.0
Installing rmagick 2.16.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
F:/RubyInstallers/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick

F:/RubyInstallers/Ruby23-x64/bin/ruby.exe -r ./siteconf20180109-35824-1fepgcv.rb

extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=F:/RubyInstallers/Ruby23-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:141:in ``': No such file or directory - identify -version
(Errno::ENOENT)
        from extconf.rb:141:in `configure_compile_options'
        from extconf.rb:16:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `
' extconf failed, exit code 1 Gem files will remain installed in F:/RubyInstallers/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection. Results logged to F:/RubyInstallers/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/rm agick-2.16.0/gem_make.out An error occurred while installing rmagick (2.16.0), and Bundler cannot continue. Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling. In Gemfile: rmagick

解决办法:查看安装文件中提示:
If ImageMagick is not installed on your system, you should skip the
installation of the rmagick gem using:

bundle install --without development test rmagick

安装成功:

这里写图片描述


五、生成会话秘钥

Generate a session store secret,Under the application main directory run。

进入到redmine的源码主目录下:

bundle exec rake generate_secret_token

六、创建数据库结构

进入redmine源码主目录下,执行:

bundle exec rake db:migrate RAILS_ENV="production"

It will create all the tables and an administrator account.

然后去你创建的redmine数据中查看是否新建了表,如果有说明这一步执行成功。


七、启动web

Under the main application directory run:

ruby bin/rails server -e production

如果看到下面信息说明web启动成功:

=> Booting WEBrick
=> Rails 4.2.8 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2018-01-09 10:59:07] INFO  WEBrick 1.3.1
[2018-01-09 10:59:07] INFO  ruby 2.3.3 (2016-11-21) [x64-mingw32]
[2018-01-09 10:59:07] INFO  WEBrick::HTTPServer#start: pid=36248 port=3000

然后浏览器打开http://localhost:3000/ 就可以看到redmine主页面了,输入默认用户名密码admin admin就可以登录了。


现在就成功的创建部署好我们的redmine环境了,关于二次开发在后文进行。

你可能感兴趣的:(redmine使用源码部署(windows))