Redmine安装维护
环境说明:
Ubuntu版本:20.04
MySQL版本:Ver 14.14 Distrib 5.7.31
Redmine版本:3.4.6.stable
一、安装
1.1官方文档
1.2安装步骤:
之前根据文档安装出来的还是3.6.4的版本,但是最近重装了一次发现是4.0.6的。两个版本之间区别就是4.0.6的附件和配置文件都默认放在/var/lib/redmine/default,3.6.4的文件都放在安装目录里面,所以不同版本之间迁移要注意这个问题。
1. 安装Apache和相关插件
$ sudo apt-get install apache2 libapache2-mod-passenger
2. 安装MySQL
$ sudo apt-get install mysql-server mysql-client
3. 安装Redmie
$ sudo apt-get install redmine redmine-mysql
4. 安装过程中先选择MySQL数据库,然后再指定redmine的密码和确认密码
5. 安装所需插件,先确保已经安装gem
$ sudo gem update
$ sudo gem install bundler
6. 配置Apache
6.1 在配置文件中添加一行PassengerDefaultUser www-data,如下图:
$ sudo vim /etc/apache2/mods-available/passenger.conf
7. 修改文件/etc/apache2/sites-available/000-default.conf,复制以下内容直接覆盖
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/redmine
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
PassengerAppRoot /usr/share/redmine
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
8. 创建符号链接
$ sudo ln -s /usr/share/redmine/public/ /var/www/html/
9. 创建并设置Gemfile.lock文件的所有权,以便apache的www-data用户可以访问它:
$ sudo touch /usr/share/redmine/Gemfile.lock
$ sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock
10. 重启服务器
$ sudo reboot
12. 访问Redmie(之前创建的链接是不带虚拟目录的)
例如:http://127.0.0.1
1.3报错信息处理
1.500错误,重启Apache服务
$ sudo service apache2 restart
2.其他错误页面,自行百度解决或者重启服务器(一般情况下都是MySQL,Apache和配置的问题)
$ sudo reboot
二、备份
1.要备份的内容:
附件:/usr/share/redmine/files
配置文件:/usr/share/redmine/config/configuration.yml(有邮件相关的配置)
/usr/share/redmine/config/database.yml(数据库相关配置)
如果安装了插件还需要备份:/usr/share/redmine/plugins
数据库:
$ sudo mysql -u用户名 –p密码 数据库名 > sql备份文件路径/文件名
三、环境迁移和还原(升级也是一样的道理)
3.1 环境本身未损坏,可以使用备份文件还原
3.1.1 把备份的文件按照对应的路径覆盖回去
3.1.2 还原数据库
$ sudo mysql -u用户名 –p密码 数据库名 < sql备份文件路径/文件名
例如:mysql -u root -p redmine < redmine.db.bak
3.1.3 重启MySQL和Apache服务
$ sudo systemctl restart mysql
$ sudo service apache2 restart
3.2 环境已经损坏无法登录
3.2.1 另找一台服务器安装redmine
3.2.2 旧环境关机,把备份好的虚拟机文件上传到服务器
3.2.3 还原备份的文件和数据库
3.3.4 重启服务器
4. 注意
目前安装在Ubuntu20.04上的Redmine导出功能不可用,目前官网也找不到解决方案,请谨慎安装
如果要使用显示附件缩略图的功能,得安装ImageMagick才能正常使用
直接在服务器上安装即可
$ sudo apt-get install imagemagick