Redmine 是一个网页界面的项目管理与缺陷跟踪管理系统的自由及开放源代码软件工具,可以同时处理多个项目。它集成了项目管理所需的各项功能,包括日历、燃尽图和甘特图以协助可视化表现项目与时间限制,问题跟踪和版本控制。本篇介绍如何安装 Redmine,以 Bitnami Redmine + Debian 10 为例,所有命令以普通用户 jinzhongxu 运行,但需要 sudo 权限。

下载安装 Redmine

这里提供两个版本,均是 bitnami 官网版本:

  1. bitnami-redmine-3.4.6-5-linux-x64-installer.run
  2. bitnami-redmine-4.2.1-3-linux-x64-installer.run

本篇以 4.2.1-3 为例,并使用 nginx 作为反向代理。需要注意的是,需要开放个别端口:

  1. 3690:svnserve
  2. 3306:mysqld
  3. 8443:httpd
  4. 8080:redmine
  5. 80,443:nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 版本 3.4.6-5
# wget https://downloads.bitnami.com/files/stacks/redmine/3.4.6-5/bitnami-redmine-3.4.6-5-linux-x64-installer.run
# chmod 755 bitnami-redmine-3.4.6-5-linux-x64-installer.run

# 版本 4.2.1-3
# 下载并赋予执行权限
wget https://downloads.bitnami.com/files/stacks/redmine/4.2.1-3/bitnami-redmine-4.2.1-3-linux-x64-installer.run
chmod 755 bitnami-redmine-4.2.1-3-linux-x64-installer.run

# 安装依赖包
sudo apt update
sudo apt install -y libncurses5 perl htop nginx

# 创建安装路径,这个路径在安装时使用
sudo mkdir -p /usr/local/redmine
sudo chown -R jinzhongxu /usr/local/redmine

# 要求内存至少 2G,如果内存不够,可以创建虚拟内存,注意以 root 用户执行
#fallocate -l 2G /swapfile
#chmod 600 /swapfile
#mkswap /swapfile
#swapon /swapfile
#cp /etc/fstab /etc/fstab.bak
#echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
#echo 'vm.swappiness=10' >> /etc/sysctl.conf
#echo 'vm.vfs_cache_pressure=50' >> /etc/sysctl.conf

# 安装
./bitnami-redmine-4.2.1-3-linux-x64-installer.run

假设服务器 IP 地址是:1.1.0.x,安装后,打开 http://1.1.0.x:8080 即可访问 redmine

配置 Nginx

假设已经购买了域名: www.redmine-test.com,并指向 IP 地址: 1.1.0.x

申请证书

下面代码以 root 身份运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 安装程序
curl https://get.acme.sh | sh -s email=xxx@yyy.com

# 使用 standalone 方式申请证书,首先需要停止 nginx,空闲 80 端口
systemctl stop nginx

~/.acme.sh/acme.sh --issue --standalone -d www.redmine-test.com -k ec-256 --ecc

# 证书存储位置
mkdir -p /etc/nginx/cert

# 安装证书
~/.acme.sh/acme.sh --installcert -d www.redmine-test.com --ecc \
--key-file /etc/nginx/cert/private.key \
--fullchain-file /etc/nginx/cert/fullchain.cer

配置 nginx

1
sudo vim /etc/nginx/nginx.conf

添加如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
user  root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 120;
client_max_body_size 20m;
#gzip on;
server {
listen 80;
listen [::]:80;
server_name www.redmine-test.com;
return 301 https://$server_name$request_uri; # 强制走 HTTPS
}
server {
listen 443 ssl;
server_name www.redmine-test.com;
ssl_certificate /etc/nginx/cert/fullchain.cer;
ssl_certificate_key /etc/nginx/cert/private.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location /redmine {
proxy_pass http://127.0.0.1:8080/redmine;
proxy_set_header Host $host;
proxy_set_header X-Real-Scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade; # redmine 4.2.1 需要注释这两行,非 websocket
# proxy_set_header Connection 'upgrade';
proxy_read_timeout 120s;
proxy_next_upstream error;
}
}
}

重启 nginx

1
sudo systemctl restart nginx.service

现在可以使用 https 协议访问 redmine,地址:https://www.redmine-test.com/redmine/

redmine 开关

查看运行状态

1
2
3
4
5
cd /usr/local/redmine
$ ./ctlscript.sh status
subversion already running
apache already running
mysql already running

关闭

1
./ctlscript.sh stop

开启

1
./ctlscript.sh start

更多配置将去如下地址查看,包括数据库登录名和密码(database.yml):/usr/local/redmine/apps/redmine/htdocs/config

把 MySQL 地址添加到环境变量,可直接在命令行运行 MySQL

1
2
3
cd
echo 'PATH=/usr/local/redmine/mysql/bin:$PATH' >> .bashrc
source .bashrc
1
mysql -u bitnami -p

参考文献

  1. Redmine安装神器:Bitnami redmine 的安装指导(Linux的安装方法)