redmine mysql 配置文件_在CentOS 8服务器上安装Redmine及配置访问Redmine的步骤

本文说明了如何在CentOS 8服务器上安装和配置Redmine的具体步骤,我们将使用MariaDB作为数据库后端,而使用Passenger+Apache作为Ruby应用程序服务器。确保有指向服务器公共IP的域名和以root或具有sudo特权的用户身份登录权限。Redmine是一个免费的开源项目管理和问题跟踪应用程序,它是跨平台和跨数据库的,建立在Ruby on Rails框架之上,Redmine包括对多个项目、Wiki、问题跟踪系统、论坛、日历、电子邮件通知等的支持。

fc568ab092caa921bad977a629ce5ff5.png

一、创建一个MySQL数据库

Redmine支持MySQL/MariaDB、Microsoft SQL Server、SQLite 3和PostgreSQL,我们将MariaDB用作数据库后端。

使用以下命令登录到MySQL Shell:

sudo mysql

在MySQL Shell中,运行以下SQL语句以创建新数据库、新用户并授予用户对该数据库的访问权限:

CREATE DATABASE redmine CHARACTER SET utf8;

GRANT ALL ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'change-with-strong-password';

确保使用强密码更改“change-with-strong-password”。

完成后,退出MySQL Shell,运行:

EXIT;

二、安装Passenger、Apache和Ruby

Passenger是一款适用于Ruby、Node.js和Python的快速,轻量级的Web应用程序服务器,可以与Apache和Nginx集成。

启用EPEL存储库:

sudo dnf install epel-release

sudo dnf config-manager --enable epel

启用存储库后,更新软件包列表并安装Ruby、Apache和Passenger:

sudo dnf install httpd mod_passenger passenger passenger-devel ruby

启动Apache服务并启用它以在启动时启动:

sudo systemctl enable httpd --now

三、创建新的系统用户

使用主目录/opt/redmine创建一个将运行Redmine实例的新用户和组:

sudo useradd -m -U -r -d /opt/redmine redmine

将apache用户添加到redmine组,并更改/opt/redmine目录权限,以便Apache可以访问它:

sudo usermod -a -G redmine apache

sudo chmod 750 /opt/redmine

四、安装Redmine

在写本文时,Redmine的稳定版本是4.1.0。

在继续下一步之前,请访问Redmine下载页面以查看是否有新版本提供下载,地址:https://www.redmine.org/projects/redmine/wiki/Download。

安装构建Redmine所需的GCC编译器和库:

sudo dnf group install "Development Tools"

sudo dnf install zlib-devel curl-devel openssl-devel mariadb-devel ruby-devel

确保以Redmine用户身份运行以下步骤:

sudo su - redmine

1.下载Redmine

使用curl下载Redmine存档:

curl -L http://www.redmine.org/releases/redmine-4.1.0.tar.gz -o redmine.tar.gz

下载完成后,解压缩存档:

tar -xvf redmine.tar.gz

2.配置Redmine数据库

复制Redmine示例数据库配置文件:

cp /opt/redmine/redmine-4.1.0/config/database.yml.example /opt/redmine/redmine-4.1.0/config/database.yml

使用文本编辑器打开文件:

nano /opt/redmine/redmine-4.1.0/config/database.yml

搜索production部分,然后输入我们之前创建的MySQL数据库和用户信息:

production:

adapter: mysql2

database: redmine

host: localhost

username: redmine

password: "change-with-strong-password"

encoding: utf8mb4

完成后,保存/opt/redmine/redmine-4.1.0/config/database.yml文件并退出编辑器。

3.安装Ruby依赖项

切换到redmine-4.1.0目录并安装Ruby依赖项:

cd ~/redmine-4.1.0

gem install bundler --no-rdoc --no-ri

bundle install --without development test postgresql sqlite --path vendor/bundle

4.生成密钥并迁移数据库

运行以下命令以生成密钥并迁移数据库:

bundle exec rake generate_secret_token

RAILS_ENV=production bundle exec rake db:migrate

五、配置Apache及SSL

1、配置Apache

切换回您的sudo用户并创建以下Apache vhost文件:

exit

sudo nano /etc/httpd/conf.d/example.com.conf

打开/etc/httpd/conf.d/example.com.conf文件编辑如下内容:

ServerName example.com

ServerAlias www.example.com

DocumentRoot /opt/redmine/redmine-4.1.0/public

Options Indexes ExecCGI FollowSymLinks

Require all granted

AllowOverride all

ErrorLog /var/log/httpd/example.com-error.log

CustomLog /var/log/httpd/example.com-access.log combined

注意:不要忘记用您的Redmine域替换example.com。

通过键入以下命令重新启动Apache服务:

sudo systemctl restart httpd

2、SSL配置

如果您的域没有受信任的SSL证书,则可以生成免费的Let’s Encrypt SSL证书,参考在CentOS 8服务器上用Let‘s Encrypt加密来保护Apache安全。

生成证书后,按如下所示编辑Apache配置:

sudo nano /etc/httpd/conf.d/example.com.conf

编辑sudo nano /etc/httpd/conf.d/example.com.conf文件,内容如下:

ServerName example.com

ServerAlias www.example.com

Redirect permanent / https://example.com/

ServerName example.com

ServerAlias www.example.com

Protocols h2 http:/1.1

Redirect permanent / https://example.com/

DocumentRoot /opt/redmine/redmine-4.1.0/public

ErrorLog /var/log/httpd/example.com-error.log

CustomLog /var/log/httpd/example.com-access.log combined

SSLEngine On

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

Options Indexes ExecCGI FollowSymLinks

Require all granted

AllowOverride all

注意:不要忘记用Redmine域替换example.com,并为SSL证书文件设置正确的路径,所有HTTP请求都将重定向到HTTPS。

六、配置访问Redmine

打开浏览器,键入您的域名,如果安装成功,将出现类似于以下的屏幕:

2cb9b66599058969c0a06f2b6c03a498.png

Redmine的默认登录帐户信息为:

用户名:admin

密码:admin

首次登录时,将提示您更改密码,如下所示:

1dae5f365f4ad54d960cbb5d57b1cbf4.png

更改密码后,您将被重定向到用户帐户页面。

如果您无法访问该页面,则可能是防火墙阻止了端口,请使用以下命令打开必要的端口:

sudo firewall-cmd --permanent --zone=public --add-port=443/tcp

sudo firewall-cmd --permanent --zone=public --add-port=80/tcp

sudo firewall-cmd --reload

至此,配置访问Redmine及安装Redmine的全部操作已完成。

相关主题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值