centos下配置redmine,以及邮件配置和优化

时间:2022-09-16 21:34:46

一、安装redmine前提要求

1. 安装redmine ruby环境版本要求:

Redmine version Supported Ruby versions Rails version used
3.3, current trunk ruby 1.9.3, 2.0.0, 2.1, 2.2, 2.3 Rails 4.2
3.2, 3.1 ruby 1.9.3, 2.0.0, 2.1, 2.2 Rails 4.2

2. 可以进入服务器,并有管理员权限

二、开始安装redmine

1. 配置环境

注:安装软件前先检查一下服务器是否已经有此软件!

yum -y install patch make gcc gcc-c++ gcc-g77 flex* bison file  
yum -y install libtool libtool-libs libtool-ltdl-devel* autoconf kernel-devel automake libmcrypt*
yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal nano sendmail
yum -y install fonts-chinese gettext gettext-devel
yum -y install gmp-devel pspell-devel
yum -y install readline* libxslt* pcre* net-snmp* gmp* libtidy*
yum -y install ImageMagick* subversion*
yum -y install wget

2. 安装mysql(如果已存在则不需要安装) rpm -qa |grep mysql

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server mysql-community-devel
rpm -qa |grep mysql #检查安装

3. 安装rvm rvm -v

curl -sSL https://get.rvm.io | bash
source /etc/profile /usr/local/rvm/bin/rvm reload
rvm -v #:未出现版本号请重装

4. 安装ruby gen -v

rvm list known  #查看可安装列表
rvm install ruby-2.1.8 #官方只支持1.9~2.2之间的版本
gem -v #如果未显示版本,重新安装ruby

5. 更新gem源

gem source -l 
gem source -r https://rubygems.org/ #:默认的url地址后必须有”/”,否则删不掉。
gem source -a https://ruby.taobao.org/
gem source -l #:确认只有 https://ruby.taobao.org/

6. 安装gem组件

gem install rails  
gem install rake
gem install mysql2

7. 配置mysql

service mysqld start
mysql -u root -p
Mysql> create database redmine default character set utf8;

grant all on redmine.* to root;
grant all on redmine.* to root@localhost;
grant all on redmine.* to redmineuser;
grant all on redmine.* to redmineuser @localhost;
set password for redmine@localhost=password('redmin');
flush privileges;
exit;

8. 安装redmine

cd /home/xhy
wget http://www.redmine.org/releases/redmine-3.1.1.tar.gz
sudo tar -zxvf redmine-3.1.1.tar.gz
sudo mv redmine-3.1.1 redmine
cd /home/xhy/redmine/

9. 配置redmine的数据文件

sudo cp config/configuration.yml.example config/configuration.yml
sudo cp config/database.yml.example config/database.yml
sudo vim /config/database.yml

production:
adapter: mysql2
database: redmine //mysql创建的database
host: localhost
username: redmine //mysql的用户名
password: redmine //mysql的用户名
encoding: utf8
port: 8035 //需要打开的端口

10. 安装管理ruby的包依赖的工具bundler

cd /home/xhy/redmine
gem install bundler #注意是在网站根目录下执行
bundle install

11. 初始化redmine

bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data #初始化数据选择zh

12 .更改权限

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

13. 开启服务

bundle exec rails server -p 8035 webrick -e production -b 0.0.0.0 -d

14. 关闭服务

ps aux | grep ruby
sudo kill -9 PID

redmine安装后的后续工作

打开redmine

输入服务器的ip地址加端口号,比如192.168.1.xxx:8035

切换ruby的版本号

rvm use 2.2.3 --default

打开服务器端口号

sudo firewall-cmd –add-port=9200/tcp –permanent
sudo systemctl restart firewalld

redmine 邮件配置方案

打开redmine的配置文件,sudo vim config/configuration.yml,然后将内容改成如下格式:

delivery_method: :async_smtp
async_smtp_settings:
address: "smtp.mxhichina.com"
port: 465
ssl: true
authentication: :login
domain: 'touchair.cn'
user_name: "xx.xiao@touxxx.cn" //邮箱账号
password: "xxxxx" //邮箱密码

redmine访问页面比较慢的解决方案

Redmine缺省配置下编辑任务时是阻塞等待通知邮件发送的,可以修改为异步方式:修改配置文件中的delivery_method为 :async_smtp,同时,修改smtp_settings为async_smtp_settings,然后重启,是不是快多了?