本文介绍在Ubuntu 16.04.1上安装redmine的过程和邮件配置,由于另外一台机器提供了mysql数据库服务,所以只写了安装mysql客户端的过程,并且为了图方便直接在root用户下面安装,过程并不是十分规范,redmine最好的方式还是建立独立的系统账号来运行。
1 安装ruby
1.1 安装RVM-ruby环境管理工具支持多版本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
1.2 更新依赖
rvm requirements
- 这里如果失败,可能apt源配置的有问题,或者源的缓存下载地有问题可以尝试修改apt源或者删除apt缓存文件后再试,修改/etc/apt/sources.list文件的内容为:
#deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
#deb http://archive.canonical.com/ubuntu/ xenial partner
#deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
- 清理apt缓存文件
rm -rf /var/lib/apt/lists/*
1.3 执行安装ruby命令
rvm install ruby-2.4.1
2 安装rails
gem install rails
gem install bundler
3 安装redmine
3.1 安装mysql客户端
apt-get install mysql-client
apt-get install libmysqlclient-dev
gem install mysql2
3.2 安装imagemagick组件库,redmine甘特图功能的依赖
sudo apt-get install imagemagick
sudo apt-get install libmagickwand-dev
gem install rmagick -v '2.16.0'
3.3 redmine安装
bundle install --without development test
#mysql5.7的数据库建库脚本
CREATE DATABASE redmine CHARACTER SET utf8mb4;
#数据库结构和数据生成
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production REDMINE_LANG=zh bundle exec rake redmine:load_default_data
#切换到redmine目录,执行相关目录的创建命令
mkdir -p tmp tmp/pdf public/plugin_assets
#官方网站是有这条命令的,由于我用的root就省略了。
#sudo chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets
3.3 redmine启动
bundle exec rails server webrick -e production -b 0.0.0.0 -p 3000 &
4 redmine邮件配置
4.1 配置redmine-3.4.5/config/configuration.yml
- 这里需要注意不是用的smtp协议的默认端口25, 而是使用的ssl端口465,经过163邮箱已经没有对外开放25端口
- password这里并不是邮箱的登陆密码,而是在163邮箱里面配置smtp服务的授权码
- 使用ssl的服务,必须加上tls:true参数
- 推荐使用异步smtp模式,这样每一个需要发邮件的操作,并不会因为需要发送邮件而影响操作的流畅度。
- delivery_method还支持:smtp :async_smtp :sendmail async_sendmail, 前面两种模式并不需要安装sendmail软件, 后面两种模式需要sendmail软件支持才能正常发邮件
default:
email_delivery:
delivery_method: :async_smtp
async_smtp_settings:
tls: true
address: smtp.163.com
port: 465
authentication: :login
domain: 163.com
user_name: 'xxxx@163.com'
password: 'xxxxx'