LoginSignup
2
6

More than 3 years have passed since last update.

CentOS 7にRedmine 4.1.1をインストールする

Posted at

概要

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なので、encoding: utf8 としている。

/var/www/redmine-4.1.1/database.yml
    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の末尾に追記。

/var/www/redmine-4.1.1/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での設定値より大きな値を記述する。

/etc/httpd/conf.d/redmine.conf
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の末尾に追記。これがないとproductionで動作しない。

/etc/httpd/conf.d/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の再起動を行って終了。

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6