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

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

公司服务器的系统是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

最后执行命令启动Ruby服务器:

ruby bin/rails server webrick -e production

此时如果安装的是Ubuntu桌面版就可以通过浏览器打开http://127.0.0.1:3000来查看Redmine的页面了,如果是服务器版本,可以通过命令w3m来查看:

w3m http://127.0.0.1:3000

如果需要在其他机器上查看的话,仅仅是ip+端口号是无法查看的,因为外部访问没有端口权限。解决方法可以通过Apache或者nginx服务器配置一个反向代理。

如果要设置为开机启动的话,可以在/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
转载请注明出处,谢谢!

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页