Contents
CentOSの設定
SELinuxを無効にする
エディタで /etc/sysconfig/selinux を開き、 SELINUX= の値を disabled に変更してください。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted変更後、CentOSを再起動して下さい。
reboot再起動後、 getenforce コマンドを実行してSELinuxが無効になったことを確認してください。 Disabled と表示されればSELinuxは無効になっています。
getenforce
DisabledfirewalldでHTTPを許可
CentOS 7.3の初期状態ではFirewalld(ファイアウォール)が有効になっているため、外部からサーバ上の80/tcpポート(HTTP)に接続することができません。クライアントのwebブラウザからアクセスできるよう、Firewalldの設定を変更します。
デフォルトzoneにhttpを追加する:
firewall-cmd --zone=public --add-service=http --permanent
success追加した設定を反映:
firewall-cmd --reload
successhttpでのアクセスが許可されたか確認:
firewall-cmd --zone=public --list-services
cockpit dhcpv6-client http ssh必要なパッケージのインストール
Redmineを使用するにあたり、必要なパッケージのインストールを行います。
開発ツール(Cコンパイラ等)のインストール
yum -y groupinstall "Development Tools"RubyとPassengerのビルドに必要なヘッダファイルなどのインストール
yum -y install openssl-devel readline-devel zlib-devel curl-devel libffi-devellibyaml-devel
PostgreSQLとヘッダファイルのインストール
yum -y install postgresql-server postgresql-develApacheとヘッダファイルのインストール
yum -y install httpd httpd-develImageMagickとヘッダファイル・日本語フォントのインストール
yum install -y epel
yum -y install ImageMagick ipa-pgothic-fonts[root@localhost ~]# yum install -y epel
メタデータの期限切れの最終確認: 0:15:18 前の 2024年11月27日 14時50分57秒 に実施しました。
引数に一致する結果がありません: epel
エラー: 一致するものが見つかりません: epel
[root@localhost ~]# yum -y install ImageMagick ipa-pgothic-fonts
メタデータの期限切れの最終確認: 0:15:31 前の 2024年11月27日 14時50分57秒 に実施しました。
引数に一致する結果がありません: ImageMagick
引数に一致する結果がありません: ipa-pgothic-fonts
エラー: 一致するものが見つかりません: ImageMagick ipa-pgothic-fonts
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y<br>Rubyのインストール
ソースコードのダウンロード
RubyのオフィシャルサイトのダウンロードページからRuby2.3の最新のソースコードをダウンロードしてください。
https://www.ruby-lang.org/ja/downloads
curl -O https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.6.tar.gzRubyのビルド
ダウンロードしたRubyのtarballを展開し、Rubyのビルドとインストールを行ってください。
tar xvf ruby-3.3.6.tar.gz
cd ruby-3.3.6
./configure --disable-install-doc
make
make install
cd ..作業後、 ruby -v を実行してRubyのバージョンを表示させ、Rubyがインストールできたことを確認してください。
ruby -v
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
bundlerのインストール
Ruby用のパッケージ管理ツールであるbundlerをインストールします。Redmineが使用するgemパッケージをインストールするのに使われます。
gem install bundler<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require': cannot load such file -- psych (LoadError)
	from <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /usr/local/lib/ruby/3.3.0/rubygems.rb:594:in `load_yaml'
	from /usr/local/lib/ruby/3.3.0/rubygems/specification.rb:1240:in `_load'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal/visitors/to_ruby.rb:351:in `call_method'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal/visitors/to_ruby.rb:182:in `visit_Gem_SafeMarshal_Elements_UserDefined'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal/visitors/visitor.rb:6:in `visit'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal/visitors/to_ruby.rb:28:in `visit'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal.rb:71:in `load'
	from /usr/local/lib/ruby/3.3.0/rubygems/safe_marshal.rb:61:in `safe_load'
	from /usr/local/lib/ruby/3.3.0/rubygems/source.rb:162:in `fetch_spec'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/index_specification.rb:98:in `spec'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/index_specification.rb:45:in `required_ruby_version'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/installer_set.rb:247:in `metadata_satisfied?'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/installer_set.rb:88:in `block in add_always_install'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/installer_set.rb:87:in `each'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/installer_set.rb:87:in `find'
	from /usr/local/lib/ruby/3.3.0/rubygems/resolver/installer_set.rb:87:in `add_always_install'
	from /usr/local/lib/ruby/3.3.0/rubygems/dependency_installer.rb:318:in `resolve_dependencies'
	from /usr/local/lib/ruby/3.3.0/rubygems/commands/install_command.rb:198:in `install_gem'
	from /usr/local/lib/ruby/3.3.0/rubygems/commands/install_command.rb:223:in `block in install_gems'
	from /usr/local/lib/ruby/3.3.0/rubygems/commands/install_command.rb:216:in `each'
	from /usr/local/lib/ruby/3.3.0/rubygems/commands/install_command.rb:216:in `install_gems'
	from /usr/local/lib/ruby/3.3.0/rubygems/commands/install_command.rb:162:in `execute'
	from /usr/local/lib/ruby/3.3.0/rubygems/command.rb:326:in `invoke_with_build_args'
	from /usr/local/lib/ruby/3.3.0/rubygems/command_manager.rb:253:in `invoke_command'
	from /usr/local/lib/ruby/3.3.0/rubygems/command_manager.rb:194:in `process_args'
	from /usr/local/lib/ruby/3.3.0/rubygems/command_manager.rb:152:in `run'
	from /usr/local/lib/ruby/3.3.0/rubygems/gem_runner.rb:56:in `run'
	from /usr/local/bin/gem:12:in `<main>'
sudo dnf install -y epel-release
sudo dnf config-manager --enable epel
sudo dnf config-manager --set-enabled crb
sudo dnf repolist | grep crb
sudo dnf install libyaml libyaml-develPostgreSQLの設定.
データベースクラスタの新規作成
postgresql-setup initdb
Initializing database ... OKRedmineからPostgreSQLに接続するための設定を追加
エディタで /var/lib/pgsql/data/pg_hba.conf を開き、 “Put your actual configuration here” と書かれている箇所を探して以下のように設定を2行追加してください。
# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records.  In that case you will also need to make PostgreSQL
# listen on a non-local interface via the listen_addresses
# configuration parameter, or via the -i or -h command line switches.
host    redmine         redmine         127.0.0.1/32            md5
host    redmine         redmine         ::1/128                 md5PostgreSQLの起動および自動起動の設定
systemctl start postgresql.service
systemctl enable postgresql.servicePostgreSQLのディレクトリに移動
cd /var/lib/pgsqlRedmine用ユーザーの作成
sudo -u postgres createuser -P redmine
新しいロールのためのパスワード: (PostgreSQLの redmine用ユーザーに設定するパスワードを入力)
もう一度入力してください: (パスワード再入力)※ PostgreSQLのユーザー redmine には任意のパスワードを設定してください。このパスワードは後述のdatabase.ymlの設定で使用します。
Redmine用データベースの作成
sudo -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redminePostgreSQLのディレクトリから元のディレクトリに戻る
cd -Redmineのインストール
Redmineのダウンロードsvn コマンドを使ってRedmine 3.4の最新ソースコード一式をRedmineのデプロイ先のディレクトリにダウンロードしてください。以下の実行例では /var/lib/ 直下のディレクトリ redmine にソースコード一式をダウンロードします。
svn co https://svn.redmine.org/redmine/branches/3.4-stable /var/lib/redminesvnコマンドを使うのではなくtarballを下記URLからダウンロードすることもできますが、svnコマンドを使う方が手間が少なく簡単です。
http://www.redmine.org/projects/redmine/wiki/Download
データベースへの接続設定
Redmineからデータベースへ接続するための設定を記述したファイルを作成します。
以下の内容でRedmineのインストールディレクトリ(例: /var/lib/redmine)以下に config/database.yml を作成してください。
production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: "********"
  encoding: utf8※ ******** 部分は、PostgreSQL上に作成したredmine用ユーザーのパスワードです。
※ config/database.yml.example に設定例が記載されているので参考にしてください。
設定ファイル config/configuration.yml の作成
Redmineからメールサーバへ接続するための設定や日本語フォントファイルのパスを記述した設定ファイルを作成します。
以下の内容で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
※ example.com の部分は、Redmineを実行するサーバのFQDNとしてください。
※ config/configuration.yml.example に設定例が記載されているので参考にしてください。 ※ メールが送信されるようにするためには別途MTAのセットアップが必要です。
configuration.yml ではアップロードされたファイルの保管場所や、データベースの暗号化なども設定できます。詳しくは configuration.yml の設定項目 をご覧ください。
Redmineのインストールディレクトリへ移動
cd /var/lib/redminegemパッケージのインストール
Rubyのパッケージ管理ツール「bundler」を使用してRedmineが依存するgemパッケージをインストールします。Redmineのインストールディレクトリで以下のコマンドを実行してください。
bundle install --without development test --path vendor/bundleRedmineの初期設定と初期データ登録
Redmine動作に関する初期設定と初期データの登録を行います。下記のコマンドはRedmineのインストールディレクトリで実行してください。
セッション改ざん防止用秘密鍵の作成
下記コマンドを実行してください。
bundle exec rake generate_secret_tokenデータベースのテーブル作成config/database.yml で指定したデータベースにテーブルを作成します。
RAILS_ENV=production bundle exec rake db:migrateデフォルトデータの登録
作成したテーブルにデフォルトデータのロードを行います。この操作によりトラッカー、優先度、ステータス、ロール、ワークフローなどの初期値が登録されます。
RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data
Default configuration data loaded.Passengerのインストール
Apache上でRedmineなどのRailsアプリケーションを実行するために使われるPhusion Passengerをインストールします。
gem install passenger -v 5.1.12 --no-rdoc --no-riPassengerのApache用モジュールのインストール
下記コマンドを実行してApache用のモジュールのビルドとインストールを行ってください。
passenger-install-apache2-module --auto --languages rubyApache用設定内容の確認
下記コマンドを実行するとApacheに追加すべき設定が表示されます。この情報はこの後Apacheの設定を行うときに使用します。
passenger-install-apache2-module --snippetApacheの設定
以下の内容で /etc/httpd/conf.d/redmine.conf を作成してください。
# Redmineの画像ファイル・CSSファイル等へのアクセスを許可する設定。
# Apache 2.4のデフォルトではサーバ上の全ファイルへのアクセスが禁止されている。
<Directory "/var/lib/redmine/public">
  Require all granted
</Directory>
# Passengerの基本設定。
# passenger-install-apache2-module --snippet で表示された設定を記述。
# 環境によって設定値が異なるため以下の5行はそのまま転記せず、必ず
# passenger-install-apache2-module --snippet で表示されたものを使用すること。
#
LoadModule passenger_module /usr/local/lib/ruby/gems/2.4.0/gems/passenger-5.1.5/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/lib/ruby/gems/2.4.0/gems/passenger-5.1.5
  PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>
# 必要に応じてPassengerのチューニングのための設定を追加(任意)。
# 詳しくはPhusion Passenger users guide(https://www.phusionpassenger.com/library/config/apache/reference/)参照。
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10
Header always unset "X-Powered-By"
Header always unset "X-Runtime"
CentOSではApache起動時に /etc/httpd/conf.d/*.conf が自動的に読み込まれます。
Apacheの起動および自動起動の設定
下記コマンドを実行し、Apacheを起動するとともにシステム起動時に自動起動されるよう設定してください。
systemctl start httpd.service
systemctl enable httpd.serviceApache上のPassengerでRedmineを実行するための設定
Redmineを配置したディレクトリ以下のファイルを、Apacheを実行するユーザー・グループ(CentOSの場合はいずれも”apache”)で読み書きできるよう、オーナーを変更します。
chown -R apache:apache /var/lib/redmineどのような形態(URL)でRedmineを利用するかによって設定が異なります。三つのパターンを例に挙げます。
パターン1: webサーバをRedmine専用として使用
webサーバのルートディレクトリでRedmineを実行するための設定です。「http://サーバIPアドレスまたはホスト名/」でRedmineにアクセスできます。
エディタで /etc/httpd/conf/httpd.conf を開き DocumentRoot をRedmineのpublicディレクトリ(例: /var/lib/redmine/public)に変更してください。
DocumentRoot "/var/www/html"
↓
DocumentRoot "/var/lib/redmine/public"設定変更後、Apacheを再起動してください。
service httpd configtest
systemctl restart httpd.serviceパターン2: サブディレクトリでRedmineを実行
URLのサブディレクトリでURLにアクセスできるように設定します(例: http://サーバIPアドレスまたはホスト名/redmine)。同じサーバでRedmine以外のアプリケーションを実行する場合や、複数のRedmineを実行する場合に便利な設定です。
前述の手順で作成したRedmine関係のApacheの設定ファイル /etc/httpd/conf.d/redmine.conf に次のような設定を追加してください。以下の設定例のうち、強調部分がサブディレクトリ名です。
Alias /redmine /var/lib/redmine/public
<Location /redmine>
  PassengerBaseURI /redmine
  PassengerAppRoot /var/lib/redmine
</Location>設定後、下記コマンドを実行してApacheを再起動してください。
service httpd configtest
systemctl restart httpd.serviceインストール完了後の初期設定
インストールが完了しwebブラウザ経由でRedmineにアクセスできる状態になったら、日本語環境で使うための設定変更やユーザーの追加・プロジェクトの追加などを行います。
インストール後の初期設定手順については以下をご覧ください。
Redmineを使い始めるための初期設定 (Redmine.JP)
この記事は役に立ちましたか?
もし参考になりましたら、下記のボタンで教えてください。
    
  
コメント