将Redmine 4.1.1安装在CentOS 7上

总结

在已安装CentOS 7的服务器上安装Redmine 4.1.1。请确保可以使用yum命令基本更新软件包。
由于情况特殊,该服务器已禁用SELinux,因此无需考虑SELinux。

引导步骤

# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

预备工作

为了安装Ruby 2.5,需要从SCL仓库中添加SCL仓库。此外,还需要添加与Ruby构建相关的必要软件包。

# yum install centos-release-scl
# yum group install "Development tools"
# yum install zlib-devel
# yum install ImageMagick ImageMagick-devel

安装Ruby和构建RoR

# yum install rh-ruby25 rh-ruby25-ruby-devel
# echo '/opt/rh/rh-ruby25/root/usr/lib64' > /etc/ld.so.conf.d/rh-ruby.conf
# ldconfig

# update-alternatives --display ruby
# update-alternatives --install /usr/bin/ruby ruby /opt/rh/rh-ruby25/root/bin/ruby 25 \
  --slave /usr/bin/gem gem /opt/rh/rh-ruby25/root/usr/bin/gem

# ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]

# gem install rails
# gem install bundler

# update-alternatives --install /usr/bin/ruby ruby /opt/rh/rh-ruby25/root/bin/ruby 25 \
  --slave /usr/bin/gem gem /opt/rh/rh-ruby25/root/usr/bin/gem \
  --slave /usr/local/bin/rails rails /opt/rh/rh-ruby25/root/usr/local/bin/rails \
  --slave /usr/local/bin/rake rake /opt/rh/rh-ruby25/root/usr/local/bin/rake \
  --slave /usr/local/bin/bundle bundle /opt/rh/rh-ruby25/root/usr/local/bin/bundle

MariaDB的安装和初始设置

# yum install mariadb-server mariadb-devel
# systemctl start mariadb
# systemctl enable mariadb
# mysql_secure_installation

# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE redmine CHARACTER SET utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON redmine.* TO redmine@localhost IDENTIFIED BY 'P@ssw0rd!';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit

Redmine的安装

# cd /var/www
# wget https://www.redmine.org/releases/redmine-4.1.1.tar.gz
# tar xvzf redmine-4.1.1.tar.gz

# cd /var/www/redmine-4.1.1/config
# cp database.yml.example database.yml
# vi database.yml

根据MariaDB的设置进行更改。因为使用的是MariaDB 5.5版本,所以将编码设置为utf8。

    production:
      adapter: mysql2
      database: redmine
      host: localhost
-     username: root
+     username: redmine
-     password: ""
+     password: "P@ssw0rd!"
      # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
-     encoding: utf8mb4
+     encoding: utf8
# cd /var/www/redmine-4.1.1
# bundle install --without development test --path vendor/bundle
# bundle exec rake generate_secret_token
# RAILS_ENV=production bundle exec rake db:migrate
# RAILS_ENV=production bundle exec rake redmine:load_default_data

# cd /var/www/redmine-4.1.1/public
# cp dispatch.fcgi.example dispatch.fcgi
# cp htaccess.fcgi.example .htaccess

# yum install httpd mod_fcgid fcgi fcgi-devel mod_ssl
# gem install fcgi

# cd /var/www/redmine-4.1.1
# vi Gemfile.local

在Gemfile.local的末尾添加内容。

+   gem 'fcgi'
# bundle install --without development test --path vendor/bundle
# chown -R apache:apache /var/www/redmine-4.1.1

Apache httpd的设置

先将DocumentRoot进行覆写设置。如果需要启用VirtualHost或SSL,可以相应地进行设置。
没有设置FcgidMaxRequestLen,上传文件大小将受到限制,因此需要编写比Redmine设置值更大的值。

DocumentRoot /var/www/redmine-4.1.1/public
FcgidMaxRequestLen 10485760
<Directory /var/www/redmine-4.1.1/public>
  Require all granted
  AllowOverride All
</Directory>

需要在fcgid.conf文件的末尾添加附加内容,如果没有这些内容,将无法在生产环境中正常运行。

    # Use FastCGI to process .fcg .fcgi & .fpl scripts
    AddHandler fcgid-script fcg fcgi fpl

    # Sane place to put sockets and shared memory file
    FcgidIPCDir /run/mod_fcgid
    FcgidProcessTableFile /run/mod_fcgid/fcgid_shm
+
+   DefaultInitEnv RAILS_ENV production

完成后,执行Firewalld的配置和Apache httpd的重新启动,并结束。

广告
将在 10 秒后关闭
bannerAds