リンク

インストール

環境

ソフトウェア バージョン
Redmine Redmine 3.3.2
OS CentOS 7.3
データベース MariaDB 5.5.52
webサーバ Apache 2.4.6
Ruby Ruby 2.0.0
Passenger Passenger 5.1.2
バージョン管理システム Git 1.8.3.1

パッケージのインストール

  • 開発環境

    # yum -y groupinstall "Development Tools"
    # yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel libffi-devel
  • Ruby (CentOS-Base リポジトリ)

    # yum -y install ruby ruby-devel
  • MariaDB

    # yum -y install mariadb-server mariadb-devel
  • Apache

    # yum -y install httpd httpd-devel
  • ImageMagickとヘッダファイル・日本語フォント

    # yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
  • bundler

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

MariaDB

  • /etc/my.cnf (抜粋)
    [mysqld]
    character-set-server=utf8
    
    [mysql]
    default-character-set=utf8
  • 起動 & サービス登録
    # systemctl start mariadb
    # systemctl enable mariadb
  • 設定確認
    # mysql -u root
    > show variables like 'character_set%'; (filesystem と dir 以外全てが utf8 になっていること)
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | utf8                       |
    | character_set_connection | utf8                       |
    | character_set_database   | utf8                       |
    | character_set_filesystem | binary                     |
    | character_set_results    | utf8                       |
    | character_set_server     | utf8                       |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    > exit
  • 初期設定
    # mysql_secure_installation
    ...
    Enter current password for root (enter for none): (そのままエンター)
    ...
    Set root password? [Y/n] (y応答)
    New password: (新 root パスワードを入力)
    Re-enter new password: (パスワード再入力)
    ...
    Remove anonymous users? [Y/n] (y応答)
    ...
    Disallow root login remotely? [Y/n] (y応答)
    ...
    Remove test database and access to it? [Y/n] (y応答)
    ...
    Reload privilege tables now? [Y/n] (y応答)
  • Redmine用データベースとユーザーの作成
    # mysql -u root -p
    > create database db_redmine default character set utf8;
    > grant all on db_redmine.* to user_redmine@localhost identified by '********';
    (******** は user_redmine 用のパスワードを記述する)
    > flush privileges;
    > exit;

Redmine のインストール

  • GitHub:redmine/redmine
    # curl -L -o redmine_3.3.2.zip https://github.com/redmine/redmine/archive/master.zip
    # unzip redmine_3.3.2.zip
    # mv redmine-master/ /var/lib/redmine
  • /var/lib/redmine/config/database.yml
    production:
      adapter: mysql2
      database: db_redmine
      host: localhost
      username: user_redmine
      password: "********"
      encoding: utf8
  • /var/lib/redmine/config/configuration.yml
    production:
      email_delivery:
        delivery_method: :smtp
        smtp_settings:
          address: "localhost"
          port: 25
          domain: "example.com"
    
      rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf

gemパッケージのインストール

# cd /var/lib/redmine
# bundle install --without development test --path vendor/bundle

Passenger のインストール (mod_passenger)

  • Installing Passenger + Apache on Red Hat 7 / CentOS 7 (with RPM) - Passenger Library

    # yum install pygpgme curl
    # curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
    # yum install -y mod_passenger || yum-config-manager --enable cr && yum install -y mod_passenger
    # /usr/bin/passenger-config validate-install (設定確認)
    # systemctl restart httpd
    # /usr/sbin/passenger-memory-stats
  • /etc/httpd/conf.d/passenger.conf

    ### Begin automatically installed Phusion Passenger config snippet ###
    <IfModule mod_passenger.c>
       PassengerRoot /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini
       PassengerRuby /usr/bin/ruby
       PassengerInstanceRegistryDir /var/run/passenger-instreg
    </IfModule>
    ### End automatically installed Phusion Passenger config snippet ###
    
    # Deploying a web application: an example
    
    # Suppose you have a web application in /somewhere. Add a virtual host to
    # your Apache configuration file and set its DocumentRoot to /somewhere/public:
    
    <VirtualHost *:80>
        ServerName redmine.example.com
        # !!! Be sure to point DocumentRoot to 'public'!
        DocumentRoot /var/lib/redmine/public
        <Directory /var/lib/redmine/public>
            # This relaxes Apache security settings.
            AllowOverride all
            # MultiViews must be turned off.
            Options -MultiViews
            # 画像ファイル・CSSファイル等へのアクセスを許可する
            Require all granted
        </Directory>
    </VirtualHost>
    
    # Passengerが追加するHTTPヘッダを削除するための設定(任意)。
    Header always unset "X-Powered-By"
    Header always unset "X-Runtime"
    
    # 必要に応じてPassengerのチューニングのための設定を追加(任意)。
    # 詳しくはPhusion Passenger users guide(https://www.phusionpassenger.com/library/config/apache/reference/)参照。
    PassengerMaxPoolSize 20
    PassengerMaxInstancesPerApp 4
    PassengerPoolIdleTime 864000
    PassengerHighPerformance on
    PassengerStatThrottleRate 10
    PassengerSpawnMethod smart
    PassengerFriendlyErrorPages off
  • Deploying a Ruby application - Apache - Passenger Library

初期設定

# bundle exec rake generate_secret_token
# RAILS_ENV=production bundle exec rake db:migrate
# RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data

SELinux

  • Fedora Manpages: passenger_selinux(8)
  • ~/SetSecurityFlags.sh
    #!/bin/bash
    
    chown -R apache. /var/lib/redmine
    chcon -Rh -t httpd_sys_content_t /var/lib/redmine
    cd /var/lib/redmine
    chcon -Rh -t httpd_log_t log
    chcon -Rh -t httpd_tmpfs_t tmp
    chcon -Rh -t httpd_sys_rw_content_t files public/plugin_assets
    find . -name '*.so' | xargs -i chcon -Rvh -t httpd_modules_t {}
    
    # リポジトリとして使用するフォルダ
    chcon -Rh -t public_content_t /home/Shared/

起動 & サービス登録

# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload
# systemctl start httpd
# systemctl enable httpd

カスタマイズ

設定

  • 「管理 - 設定」から各項目を変更。
  • 表示
    • 日付の形式: yyyy-mm-dd
    • 時刻の形式: hh:mm (24時制)
  • チケットトラッキング
    • 現在の日付を新しいチケットの開始日とする: チェック外す
    • 進捗の算出方法: チケットのステータスに連動
  • メール通知
  • リポジトリ
    • 参照用キーワード: 「*」を追加。(参照用キーワード無しでリビジョンとチケットを関連づける)

トラッカー

  • 「機能, サポート, バグ」に順序を変更。

チケットのステータス

  • ステータス更新後、「進捗率の更新」をクリック。 | ステータス | 進捗率 | 終了したチケット | | --- | --- | --- | | 新規 | | | | 進行中 | 50 | | | 解決 | 100 | v | | フィードバック | 70 | | | 終了 | 100 | v | | 却下 | 100 | v |

プラグイン

  • GitHub:yukkyna/redmine-export-project-data
    • プロジェクト一式をファイルとしてエクスポートする。
    • エクスポート
      # cd /var/lib/redmine/
      # RAILS_ENV=production rake 'project_data:export[identifier,destdir]'
    • インポート
# cd /var/lib/redmine/
# cp -R destdir/files/ .
# chown -R apache. files/
# chcon -Rh -t httpd_sys_content_t files/
# cat destdir/identifier.sql | mysql -u user_redmine -p db_redmine