2015年Ubuntu最新Redmine的安装和配置

近期须要在公司内部搭建一个项目管理平台Redmine,在摸索了一天之后。最终配置成功,在这里分享给大家。

公司server的系统是Ubuntu14.04,要安装的是最新的Redmine3.0。

因为Redmine是基于Ruby On Rails安装的。所以第一步是安装Ruby On Rails。这部分能够參考我的上一篇博文《Ubuntu Ruby On Rails安装和配置》

PostgreSQL安装完Ruby On Rails之后,下一步是安装数据库。Redmine支持的数据库有MySQL、PostgreSQL、Microsoft SQL Server、SQLite3。本人选用的是MySQL,这里以MySQL为例。运行下面命令:

sudo apt-get install mysql-server mysql-client

然后是创建用户和数据库:

mysql -u root -p

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

当中redmine是用户名,my_password是密码。创建完之后须要下载Redmine的源代码:

hg clone --updaterev 3.0-stable https://bitbucket.org/redmine/redmine-all redmine-3.0

下载完之后,切换到该文件夹,运行命令:

cp  config/database.yml.example config/database.yml

将production的配置改动为:

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: my_password

接下来安装gem的依赖项:

gem install bundler
bundle install

安装前注意因为默认镜像国内无法訪问,所以须要切换源:

$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org
# 请确保唯独 ruby.taobao.org
$ gem install rails

在运行bundle install的过程中可能会报错,依据提示逐个解决就可以。再接下来须要初始化数据库,依次运行下面命令:
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
下一步须要改动文件权限:

mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

最后运行命令启动Rubyserver:

ruby bin/rails server webrick -e production

此时假设安装的是Ubuntu桌面版就能够通过浏览器打开http://127.0.0.1:3000来查看Redmine的页面了,假设是server版本号,能够通过命令w3m来查看:

w3m http://127.0.0.1:3000

假设须要在其它机器上查看的话,不过ip+port号是无法查看的。因为外部訪问没有port权限。解决方法能够通过Apache或者nginxserver配置一个反向代理。

假设要设置为开机启动的话,能够在/etc/init.d文件夹下创建redmine文件。编辑内容:

# !/bin/sh
#
# description: Auto-starts redmine
# processname: redmine

cd /var/www/redmine-3.0/ && ruby bin/rails server webrick -e production -d

赋予该文件运行权限并设置为开机启动:

sudo chmod 755 /etc/init.d/redmine
sudo update-rc.d redmine defaults 95

下面给出一些错误相应的解决方法:

1. There was an error while trying to write to Gemfile.lock. It is likely that you need to allow write permissions for the file at path: /home/thiago/model/Gemfile.lock

http://stackoverflow.com/questions/17519090/gemfile-lock-write-error-permissions

sudo chown -R $(whoami):$(whoami) myappfolder

2. No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'

http://stackoverflow.com/questions/27204494/unable-to-install-fileutils-rubygem-on-ubuntu-14-04-lts

sudo apt-get install libmagickwand-dev

3. Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

http://stackoverflow.com/questions/10051448/error-failed-to-build-gem-native-extension-mysql2-on-rails-3-2-3

sudo apt-get install mysql-client libmysqlclient-dev

假设大家认为对自己有帮助的话。还希望能帮顶一下,谢谢:)
个人博客:http://blog.csdn.net/zhaoxy2850
本文地址:http://blog.csdn.net/zhaoxy_thu/article/details/44310677
转载请注明出处。谢谢!

原文地址:https://www.cnblogs.com/cynchanpin/p/6785119.html