在 CentOS/RHEL 8 上安装 EPEL 存储库:

Redmine 软件的一些必备软件包在标准 yum 存储库中不可用,因此,我们需要在 Linux 服务器上安装 EPEL yum 存储库。

在 CentOS 8 上安装 EPEL 并启用所需的 repo。

# dnf install -y epel-release
# dnf config-manager --set-enabled PowerTools

在 RHEL 8 上安装 EPEL 并启用所需的 repo。

# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# subscription-manager repos --enable "codeready-builder-for-rhel-8-x86_64-rpms"
Repository 'codeready-builder-for-rhel-8-x86_64-rpms' is enabled for this system.

为新添加的 yum 存储库构建缓存。

# dnf makecache

安装 Redmine 项目管理软件:

切换到 redmineuser 开始安装项目管理软件。

# su - redmineuser

访问 https://www.redmine.org/projects/redmine/wiki/download
找到最新稳定版本的 URL。

然后使用 wget 命令下载 Redmine 安装程序。

$ wget https://www.redmine.org/releases/redmine-4.2.2.tar.gz

将下载的 zip 文件解压缩到 /opt/redmineuser 目录。

$ tar xzf redmine-4.2.2.tar.gz -C /opt/redmineuser/ --strip-components=1

使用示例配置文件, 创建 Redmine 配置文件。

$ cd /opt/redmineuser/
$ cp config/configuration.yml.example config/configuration.yml
$ cp config/database.yml.example config/database.yml
$ cp public/dispatch.fcgi.example public/dispatch.fcgi

在 vim 文本编辑器中编辑 database.yml 文件。

$ vi config/database.yml

在以下部分中查找并配置数据库连接设置。

production:
  adapter: mysql2
  database: redminedb
  host: localhost
  username: redmineadmin
  password: "P@ssw0rd"
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4

执行以下 gem 命令来安装 bundler 来管理 ruby gem 依赖项。

$ gem install bundler
Fetching: bundler-2.2.25.gem (100%)
Successfully installed bundler-2.2.25
Parsing documentation for bundler-2.2.25
Installing ri documentation for bundler-2.2.25
Done installing documentation for bundler after 7 seconds
1 gem installed

设置环境并安装gem依赖如下。

$ bundle config set --local without 'development test'
$ bundle install
...
Fetching roadie-rails 2.2.0
Installing rails 5.2.6
Installing roadie-rails 2.2.0
Bundle complete! 37 Gemfile dependencies, 63 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

如果我们在 gems 版本中遇到冲突,那么我们可以执行以下命令将 gems 恢复到原始状态。

$ sudo gem pristine --all

为防止篡改存储会话数据的 cookie,我们需要生成一个随机密钥。

$ bundle exec rake generate_secret_token

通过执行以下命令创建数据库结构。

$ RAILS_ENV=production bundle exec rake db:migrate

将默认配置数据插入到 MySQL 数据库中。

$ RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data
Default configuration data loaded.

创建必要的目录并调整文件权限。

$ mkdir -p tmp/pdf
$ mkdir -p public/plugin_assets
$ chown -R redmineuser:redmineuser files log tmp public/plugin_assets
$ chmod -R 755 /opt/redmineuser/

执行以下命令以使用 WEBrick 启动 Rails 服务器实例。

$ bundle exec rails server webrick -e production

使用浏览器打开:

http://192.168.116.238:3000/login。

使用默认凭据登录: admin/admin。

Redmine项目管理软件已经安装成功。

在 CentOS/RHEL 8 上安装 Phusion Passenger

Phusion Passenger 是一个 ruby 应用服务器,可用于通过 Apache Web 服务器为 Redmine 提供服务。

我们可以使用以下 gem 命令安装Passenger。

$ gem install passenger --no-rdoc --no-ri
Fetching: passenger-6.0.10.gem (100%)
Building native extensions. This could take a while...
Successfully installed passenger-6.0.10
1 gem installed

在Apache Web 服务器上安装Passenger 模块。

$ passenger-install-apache2-module

在执行上述命令期间,系统会要求我们创建以下配置文件。

因此,以 root 用户身份打开另一个 ssh 会话并执行以下配置。

使用 vim 文本编辑器创建 Apache 模块配置文件。

# vi /etc/httpd/conf.modules.d/00-passenger.conf

在此文件中添加以下指令。

LoadModule passenger_module /opt/redmineuser/.gem/ruby/gems/passenger-6.0.10/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /opt/redmineuser/.gem/ruby/gems/passenger-6.0.10
     PassengerDefaultRuby /usr/bin/ruby
   </IfModule>

使用 vim 文本编辑器创建 Apache 配置文件。

# vi /etc/httpd/conf.d/redmine.conf

在此文件中添加以下指令。

Listen 3000
<IfModule mod_passenger.c>
  PassengerRoot /opt/redmineuser/.gem/ruby/gems/passenger-6.0.10
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>
<VirtualHost *:3000>
    ServerName redmine-01.onitroad.com
    DocumentRoot "/opt/redmineuser/public" 
    CustomLog logs/redmine_access.log combined
    ErrorLog logs/redmine_error_log
    LogLevel warn
    <Directory "/opt/redmineuser/public">
        Options Indexes ExecCGI FollowSymLinks
        Require all granted
        AllowOverride all
    </Directory>
</VirtualHost>

通过执行以下命令验证 Apache 配置。

# httpd -t
Syntax OK

重新启动 Apache 服务以加载更改。

# systemctl restart httpd.service

使用 gems 命令的Passenger安装不提供 SELinux 配置。

因此,我们必须在 Linux 服务器上禁用 SELinux。

# setenforce 0
# sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config

使用浏览器打开:

http://192.168.116.238:3000/login。

安装 MySQL 数据库服务器:

Redmine 软件目前支持 PostgreSQL 和 MySQL 数据库。
在这里,我们使用 MariaDB 数据库服务器并将其配置为项目管理应用程序的后端。

以 root 用户身份连接 MySQL 数据库实例。

# mysql -u root -p

在 MySQL shell 执行以下命令,为 Redmine 软件创建数据库和用户。

MariaDB [(none)]> create database redminedb;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> grant all on redminedb.* to redmineadmin@localhost identified by 'P@ssw0rd';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit
Bye

在 CentOS/RHEL 8 上安装 Apache Web 服务器:

Redmine 软件需要一个网络服务器来部署它的应用程序。
因此,执行 dnf 命令并在 Linux 服务器上安装 Apache。

# dnf install -y httpd

启用并启动 Apache Web 服务器。

# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

将 redmineuser 组授予 apache 用户,使其对 /opt/redmineuser 目录中的文件具有必要的访问权限。

# usermod -aG redmineuser apache
如何在 CentOS/RHEL 8 上安装 Redmine

Redmine 是一个免费、开源、基于 Web 的项目管理和问题跟踪工具。

它允许用户管理多个项目和关联的子项目。
它具有每个项目的 wiki 和论坛、时间跟踪和灵活的、基于角色的访问控制。
它包括一个日历和甘特图,以帮助直观地表示项目及其截止日期。
Redmine 与各种版本控制系统集成,并包括存储库浏览器和差异查看器。

Redmine 是使用 Ruby on Rails 框架编写的。

它是跨平台和跨数据库的,支持 49 种语言。

本文将介绍在CentOS/RHEL 8 上安装 Redmine

为 Redmine 创建 Linux 用户:

我们将在 /opt/redmineuser 中安装 Redmine 项目管理软件。

因此,创建一个 Linux 用户并将 /opt/redmineuser 设置为其主目录。

# useradd -r -m -d /opt/redmineuser redmineuser

设置 redmineuser 的密码。

# passwd redmineuser

向 redmineuser 授予 sudo 权限,这是执行 bundle 命令所必需的。

# usermod -aG wheel redmineuser

配置 Linux 防火墙:

Redmine 是用 Ruby 编程语言编写的。
Ruby Web 服务器的默认端口是 3000/tcp。

因此,我们需要在 Linux 防火墙中添加此端口,以使应用程序可以通过网络访问。

# firewall-cmd --add-port=3000/tcp --permanent
Success
# firewall-cmd --reload
Success
之路 on it Road.com

安装 Redmine 准备工作:

如果我们按照上述步骤设置了 yum 存储库,那么我们可以使用单个 dnf 命令轻松安装所有准备工作。

# dnf install -y ruby ruby-devel rpm-build wget libxml2-devel make automake libtool ImageMagick ImageMagick-devel mariadb-devel httpd-devel openssl-devel libcurl-devel gcc gcc-c++

检查我们安装的 ruby 的版本。

# ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
日期:2020-09-17 00:12:34 来源:oir作者:oir