Image

知识库 → 在 VPS Centos 7 上安装 redmine

[虚拟服务器] [VPS/VDS 上的应用]
出版日期: 16.09.2023

在本指南中,我们在运行 Centos 7 操作系统的 VPS 服务器上设置了 Redmine 应用程序。任务是获得一个现成的服务器,其中包含可运行的应用程序并在必要时清除设置。 我们需要安装数据库、附加包、Ruby 并设置 Nginx Web 服务器。 在本指南中,我们以 root 用户身份安装,如果您有普通用户,请使用 sudo 命令。

订购单上提供预配置的服务器配置.
版本 4.2.8

订购单上提供预配置的服务器配置.

1. 安装 MariaDB 数据库

yum update
yum install epel-release
vi /etc/yum.repos.d/MariaDB.repo

复制下面的配置:

# MariaDB 10.9 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/

[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.9/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

让我们安装服务:

yum install MariaDB-client MariaDB-server
systemctl enable mariadb.service
systemctl restart mariadb.service

创建一个新的数据库和用户

mysql
mysql> CREATE DATABASE redmine CHARACTER SET utf8;
mysql> GRANT ALL ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'You_pasw0Rd-967';
mysql> EXIT;

2. 安装所需的包

yum install curl gpg gcc gcc-c++ make patch autoconf automake bison libffi-devel libtool
yum install readline-devel sqlite-devel zlib-devel openssl-devel readline glibc-headers glibc-devel
yum install mariadb-devel zlib libyaml-devel bzip2 ImageMagick ImageMagick-devel
yum install yum-utils pygpgme
yum-config-manager --add-repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
yum install nginx passenger passenger-devel nginx-mod-http-passenger

让我们添加一个用户:

useradd -m -U -r -d /opt/redmine redmine
usermod -a -G redmine nginx
chmod 750 /opt/redmine

3. Redmine安装

su - redmine
$gpg --keyserver keyserver.ubuntu.com --recv-key 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$curl -sSL https://get.rvm.io | bash -s stable
$source /opt/redmine/.rvm/scripts/rvm
$rvm install 2.7
$rvm --default use 2.7
$wget http://www.redmine.org/releases/redmine-4.2.8.tar.gz
$tar -xvf redmine-4.2.8.tar.gz
$cp /opt/redmine/redmine-4.2.8/config/database.yml.example /opt/redmine/redmine-4.2.8/config/database.yml

让我们根据在数据库中创建的用户来编辑文件:

$vi /opt/redmine/redmine-4.2.8/config/database.yml

production: adapter: mysql2 database: redmine host: localhost username: redmine password: "You_pasw0Rd-967" encoding: utf8

保存文件并安装必要的包:

$cd ~/redmine-4.2.8
$gem install bundler
$bundle install --without development test postgresql sqlite
$bundle exec rake generate_secret_token
$RAILS_ENV=production bundle exec rake db:migrate
$exit

5. 设置 Nginx 

打开文件并将配置粘贴到那里:

#vi /etc/nginx/conf.d/example.com.conf

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /opt/redmine/.rvm/gems/default/wrappers/ruby; passenger_instance_registry_dir /var/run/passenger-instreg;

server { listen 80; server_name example.com www.example.com; root /opt/redmine/redmine-4.2.8/public;

log files

access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; passenger_enabled on; passenger_min_instances 1; client_max_body_size 10m; }

保存文件并注释掉默认 nginx 模块文件中的重复行:

vi /etc/nginx/conf.d/passenger.conf

#passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini; #passenger_ruby /usr/bin/ruby; #passenger_instance_registry_dir /var/run/passenger-instreg;

使用命令检查配置 

nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl restart nginx
systemctl enable nginx

完成,下面我们给出了使用 SSL 证书的 nginx 配置,如果可用,请使用它并在文件中指定您的域。 在我们的例子中,我们使用了 IP 地址。 

5.1 使用 SSL 证书设置 Nginx 

/etc/nginx/conf.d/example.com.conf

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /opt/redmine/.rvm/gems/default/wrappers/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;

Redirect HTTP -> HTTPS

server { listen 80; server_name www.example.com example.com;

include snippets/letsencrypt.conf; return 301 https://example.com$request_uri;

}

Redirect WWW -> NON WWW

server { listen 443 ssl http2; server_name www.example.com;

ssl_certificate /etc/ssl/example.com/fullchain.pem; ssl_certificate_key /etc/ssl/example.com/privkey.pem; ssl_trusted_certificate /etc/ssl/example.com/chain.pem; include snippets/ssl.conf; return 301 https://example.com$request_uri;

}

server {

listen 443 ssl http2; server_name example.com; root /opt/redmine/redmine-4.2.8/public;

SSL parameters

ssl_certificate /etc/ssl/example.com/fullchain.pem; ssl_certificate_key /etc/ssl/example.com/privkey.pem; ssl_trusted_certificate /etc/ssl/example.com/chain.pem; include snippets/ssl.conf; include snippets/letsencrypt.conf;

log files

access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log;

passenger_enabled on; passenger_min_instances 1; client_max_body_size 10m;

}

重新启动服务以应用设置:

systemctl restart nginx

Redmine 安装成功完成。





暂时没有评论