# CentOS8中如何部署Redmine項目管理和缺陷跟蹤系統
## 一、Redmine簡介與部署準備
### 1.1 Redmine核心功能
Redmine是一款開源的、基于Web的項目管理和缺陷跟蹤系統,采用Ruby on Rails框架開發,具有以下核心功能:
- 多項目管理支持
- 靈活的基于角色的訪問控制
- 問題跟蹤系統(缺陷管理)
- Gantt圖和日歷視圖
- 新聞、文檔和文件管理
- 電子郵件通知
- 與版本控制系統集成(SVN、CVS、Git等)
- 支持多種數據庫(MySQL/MariaDB、PostgreSQL等)
### 1.2 系統環境要求
在CentOS 8上部署Redmine需要滿足以下環境要求:
- **操作系統**:CentOS 8.x(建議最小化安裝)
- **內存**:至少2GB(生產環境建議4GB以上)
- **存儲空間**:至少10GB可用空間
- **軟件依賴**:
- Ruby 2.6+
- Rails 5.2+
- 數據庫(MySQL/MariaDB或PostgreSQL)
- Web服務器(Apache/Nginx)
### 1.3 準備工作
1. 更新系統:
```bash
sudo dnf update -y
sudo reboot
安裝EPEL倉庫:
sudo dnf install epel-release -y
sudo dnf config-manager --set-enabled powertools
安裝基礎工具:
sudo dnf install -y wget curl tar unzip git make gcc gcc-c++ patch
Redmine支持多種數據庫,這里以MariaDB為例:
sudo dnf install -y mariadb-server mariadb-devel
sudo systemctl enable --now mariadb
運行安全安裝腳本:
sudo mysql_secure_installation
按照提示設置root密碼并移除匿名用戶、測試數據庫等。
mysql -u root -p
# 在MySQL shell中執行:
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;
EXIT;
安裝RVM依賴:
sudo dnf install -y gnupg2 autoconf automake bison libffi-devel \
libtool readline-devel sqlite-devel openssl-devel zlib-devel
安裝RVM:
gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
安裝Ruby 2.7:
rvm install 2.7
rvm use 2.7 --default
ruby -v # 應顯示ruby 2.7.x
gem -v # 檢查gem版本
wget https://www.redmine.org/releases/redmine-4.2.3.tar.gz
tar xvf redmine-4.2.3.tar.gz
sudo mv redmine-4.2.3 /opt/redmine
編輯配置文件:
cd /opt/redmine
cp config/database.yml.example config/database.yml
vim config/database.yml
修改production部分:
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "your_strong_password"
encoding: utf8mb4
安裝Bundler:
gem install bundler
安裝依賴包:
bundle config set --local without 'development test'
bundle install
bundle exec rake generate_secret_token
RLS_ENV=production bundle exec rake db:migrate
RLS_ENV=production bundle exec rake redmine:load_default_data
# 選擇語言(zh為簡體中文)
gem install passenger --no-document
passenger-install-nginx-module --auto --prefix=/opt/nginx \
--auto-download --languages ruby
創建Nginx服務文件:
sudo vim /etc/systemd/system/nginx.service
內容如下:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MNPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
配置Nginx支持Redmine:
sudo vim /opt/nginx/conf/nginx.conf
在http塊中添加:
server {
listen 80;
server_name your_domain.com;
root /opt/redmine/public;
passenger_enabled on;
passenger_ruby /usr/local/rvm/gems/ruby-2.7.6/wrappers/ruby;
client_max_body_size 10m;
location ~ ^/attachments {
passenger_enabled on;
expires 30d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
sudo systemctl daemon-reload
sudo systemctl enable --now nginx
sudo setsebool -P httpd_can_network_connect 1
cd /opt/redmine
cp config/configuration.yml.example config/configuration.yml
vim config/configuration.yml
示例配置(以Gmail為例):
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "smtp.gmail.com"
port: 587
domain: "yourdomain.com"
authentication: :plain
user_name: "your_email@gmail.com"
password: "your_password"
enable_starttls_auto: true
RLS_ENV=production bundle exec rails console
> ActionMailer::Base.delivery_method = :smtp
> ActionMailer::Base.smtp_settings = YAML.load_file('config/configuration.yml')['production']['email_delivery']['smtp_settings']
> ActionMailer::Base.perform_deliveries = true
> Mail.deliver do
> to 'test@example.com'
> from 'admin@example.com'
> subject 'Redmine郵件測試'
> body '這是一封測試郵件'
> end
http://your_server_ip可能原因: - Passenger未正確安裝 - Ruby路徑配置錯誤
解決方法:
passenger-config validate-install
passenger-memory-stats
檢查database.yml配置,確保:
- 數據庫服務正在運行
- 用戶名密碼正確
- 數據庫已創建
測試命令:
RLS_ENV=production bundle exec rake redmine:email:test[test@example.com]
創建備份腳本/opt/redmine/backup.sh:
#!/bin/bash
DATE=$(date +%Y%m%d)
BACKUP_DIR="/opt/redmine_backups"
mkdir -p $BACKUP_DIR
mysqldump -u redmine -p'your_password' redmine | gzip > $BACKUP_DIR/redmine_db_$DATE.sql.gz
tar czf $BACKUP_DIR/redmine_files_$DATE.tar.gz /opt/redmine/files
重要日志位置:
- Redmine日志:/opt/redmine/log/production.log
- Nginx訪問日志:/opt/nginx/logs/access.log
- Nginx錯誤日志:/opt/nginx/logs/error.log
本文詳細介紹了在CentOS 8系統上部署Redmine的完整流程,包括: 1. 系統環境準備 2. MariaDB數據庫安裝配置 3. Ruby環境搭建 4. Redmine核心安裝 5. Nginx+Passenger集成 6. 郵件系統配置 7. 基礎使用和安全建議
通過以上步驟,您已經成功搭建了一個功能完整的Redmine項目管理平臺。后續可以根據團隊需求安裝插件、定制工作流程或進行性能優化。 “`
這篇文章提供了從零開始部署Redmine的完整指南,包含約2800字的詳細步驟和技術細節,采用Markdown格式編寫,可直接用于技術文檔發布。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。