Joruri CMS 2020 インストール手順

公開日 2020年10月21日

更新日 2025年03月27日

はじめに

Joruri CMS 2020のインストール手順は下記の通りです。

この手順書はインストールの概要を把握していただくためのサンプルです。
実際のインストールではこれ以外にセキュリティ関連の設定などを行います。

ソースコードを配布した方は、./doc内に最新のインストール手順書がありますので、そちらを参考にインストールを行ってください。

オールインワンでのインストール

この手順書のインストールは、1台のサーバーにWebサーバー、CMSサーバー、DBサーバーをインストールするオールインワンの構成の場合です。

自治体公式サイトとしてご利用の場合は、公開用のWebサーバーとCMSサーバーを分離する構成を推奨します。
サーバーを分離すると、公開画面に大きな負荷がかかった場合も、管理画面の操作に影響しません。

サーバーを分割したインストール

複数のサーバーでCMSのシステムを構成する場合、各サーバー間のデータ転送の設定を行います。
これらの設定手順は、弊社にサーバー構築をご依頼いただいたお客様のみに公開いたします。

一部のお客様において、インストール手順が公開されていることが問題と考える方がいらっしゃいます。
このため詳細なインストール手順を不特定多数に公開することは差し控えることとします。

1.想定環境

システム

  • OS: AlmaLinux9
  • Webサーバー: nginx 1.26
  • Appサーバー: unicorn 6.1
  • Database: PostgreSQL 15
  • Ruby: 3.3.4
  • Rails: 7.1.3.4

前提条件

1台のサーバーマシンにJoruriをインストールします。 OSはインストール済みとします。

  • サイト名: Joruri
  • サイトURL: joruri.example.com

2.作業ユーザーの変更

rootユーザーに変更します。

$ su -

インストールの作業ログを取得する場合は下記を実行します。

# script /root/joruri_install.log

3.SELinuxの変更

SELinuxを変更します。

# setenforce 0
# vi /etc/sysconfig/selinux
---
SELINUX=permissive    # 変更
---

※セキュリティ設定は環境に応じて適切に設定してください。

4.事前準備

ロケールを日本語に設定します。

# localectl set-locale LANG=ja_JP.UTF-8
# localectl

crbを有効にします。

# dnf config-manager --set-enabled crb

作業に必要なパッケージをインストールします。

# dnf -y install git epel-release

5.Rubyのインストール

必要なパッケージをインストールします。

# dnf -y install gcc-c++ libffi-devel libyaml-devel make openssl-devel readline-devel zlib-devel bzip2 perl jemalloc-devel

rbenvをインストールします。

# git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv
# git clone https://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build
# git clone https://github.com/rbenv/rbenv-vars.git /usr/local/rbenv/plugins/rbenv-vars

# echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile.d/rbenv.sh
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile.d/rbenv.sh
# echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
# source /etc/profile.d/rbenv.sh

rubyをインストールします。

# rbenv install 3.3.4
# rbenv global 3.3.4
# rbenv rehash
# ruby -v

6.Node.jsのインストール

nodenvをインストールします。

# git clone https://github.com/nodenv/nodenv.git /usr/local/nodenv
# git clone https://github.com/nodenv/node-build.git /usr/local/nodenv/plugins/node-build

# echo 'export NODENV_ROOT="/usr/local/nodenv"' >> /etc/profile.d/nodenv.sh
# echo 'export PATH="${NODENV_ROOT}/bin:${PATH}"' >> /etc/profile.d/nodenv.sh
# echo 'eval "$(nodenv init -)"' >> /etc/profile.d/nodenv.sh
# source /etc/profile.d/nodenv.sh

nodejsをインストールします。

# nodenv install 20.15.0
# nodenv global 20.15.0
# nodenv rehash
# node -v

yarnをインストールします。

# npm install -g yarn
# nodenv rehash
# yarn -v

7.nginxのインストール

外部からhttpでアクセス可能にします。 ※ファイアーウォール設定は環境に応じて適切に設定してください。

# firewall-cmd --add-service=http --zone=public --permanent
# firewall-cmd --reload
# firewall-cmd --list-all

dnfリポジトリに追加します。

# vi /etc/yum.repos.d/nginx.repo
---
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
---

インストールします。

# dnf -y install nginx
# nginx -v

8.PostgreSQLのインストール

yumリポジトリを追加します。

# dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

インストールします。

# dnf -y install postgresql15-server postgresql15-contrib postgresql15-devel
# psql -V

データベースを初期化します。

# /usr/pgsql-15/bin/postgresql-15-setup initdb

ユーザー認証方法を変更します。

# vi /var/lib/pgsql/15/data/pg_hba.conf
---
host    all             all             127.0.0.1/32            scram-sha-256
---

postgresqlを起動します。

# systemctl start postgresql-15

接続を確認します。

# su - postgres -c "psql -c 'select version()'" 

9.Postfixのインストール

インストールします。

# dnf -y install postfix
# postconf mail_version

10.ふりがな・読み上げツールのインストール

必要なパッケージをインストールします。

# dnf -y install sox
# sox --version

hts_engine APIをインストールします。

# cd /usr/local/src
# curl -fsSLO http://downloads.sourceforge.net/hts-engine/hts_engine_API-1.09.tar.gz
# tar zxf hts_engine_API-1.09.tar.gz && cd hts_engine_API-1.09 && ./configure CFLAGS='-O3 -march=native -funroll-loops' && make && make install

Open JTalkをインストールします。

# cd /usr/local/src
# curl -fsSLO http://downloads.sourceforge.net/open-jtalk/open_jtalk-1.08.tar.gz
# tar zxf open_jtalk-1.08.tar.gz && cd open_jtalk-1.08
# sed -i 's/#define MAXBUFLEN 1024/#define MAXBUFLEN 10240/' bin/open_jtalk.c
# ./configure --with-charset=UTF-8 CFLAGS='-O3 -march=native -funroll-loops' CXXFLAGS='-O3 -march=native -funroll-loops' && make && make install
# open_jtalk -h

Dictionaryをインストールします。

# cd /usr/local/src
# curl -fsSLO http://downloads.sourceforge.net/open-jtalk/open_jtalk_dic_utf_8-1.08.tar.gz
# tar zxf open_jtalk_dic_utf_8-1.08.tar.gz
# mkdir /usr/local/share/open_jtalk && mv open_jtalk_dic_utf_8-1.08 /usr/local/share/open_jtalk/dic

LAMEをインストールします。

# cd /usr/local/src
# curl -fsSLO http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
# tar zxf lame-3.99.5.tar.gz && cd lame-3.99.5 && ./configure && make && make install
# lame --version

MeCabをインストールします。

# cd /usr/local/src
# curl -fsSL 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE' -o mecab-0.996.tar.gz
# tar zxf mecab-0.996.tar.gz && cd mecab-0.996 && ./configure --enable-utf8-only && make && make install
# mecab -v

MeCab-IPAdicをインストールします。

# cd /usr/local/src
# curl -fsSL 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM' -o mecab-ipadic-2.7.0-20070801.tar.gz
# tar zxf mecab-ipadic-2.7.0-20070801.tar.gz && cd mecab-ipadic-2.7.0-20070801 && ./configure --with-charset=utf8 && make && make install

MeCab-Rubyをインストールします。

# cd /usr/local/src
# curl -fsSL 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7VUNlczBWVDZJbE0' -o mecab-ruby-0.996.tar.gz
# tar zxf mecab-ruby-0.996.tar.gz && cd mecab-ruby-0.996 && ruby extconf.rb && make && make install

libmecabのパスを設定します。

# echo '/usr/local/lib' >> /etc/ld.so.conf.d/usrlocal.conf
# ldconfig
# ldconfig -p | grep "/usr/local/lib"

11.Joruriのインストール

専用ユーザーを作成します。

# useradd -m joruri

DB接続用のユーザーを作成します。 ※パスワードは任意の文字列を設定してください。(ここでは「joruripass」とします。)

# su - postgres -c "psql -c \"CREATE USER joruri WITH CREATEDB ENCRYPTED PASSWORD 'joruripass';\""

必要なパッケージをインストールします。

# dnf -y install http://repo.okay.com.mx/centos/9/x86_64/release/okay-release-1-10.el9.noarch.rpm
# dnf -y install libxml2-devel libxslt-devel openldap-devel patch zip exiv2 rsync
# dnf -y install ImageMagick-devel libwebp-tools
# convert -version

専用ディレクトリを作成します。

# mkdir -p /var/www/joruri
# chown joruri:joruri /var/www/joruri

joruriユーザーに変更します。

# su - joruri
$ cd /var/www/joruri

Joruriを設置します。

[パスワード認証を使用する場合]
# git clone https://github.com/joruri/joruri-cms-2020.git /var/www/joruri

[デプロイキーを使用する場合]
$ ssh-keygen -t rsa
$ more /home/joruri/.ssh/id_rsa.pub
---
  (表示された鍵をGitHubリポジトリに登録)
---
$ git clone git@github.com:joruri/joruri-cms-2020.git /var/www/joruri

[取得済みのソースコードをアップロードする場合]
ソースコードをサーバーの下記のパスにアップロードし、所有者をjoruriに変更します。
---
/var/www/joruri
---
$ chown -R joruri:joruri /var/www/joruri

パーミッションを変更します。

$ find /var/www/joruri -type d -exec chmod 755 {} \;

ライブラリをインストールします。

$ bundle config build.pg --with-pg-config=/usr/pgsql-15/bin/pg_config
$ bundle install --path vendor/bundle --without development test
$ bundle list

12.Joruriの設定

サンプルの設定ファイルをコピーします。

$ cp -p /var/www/joruri/config/original/*.yml /var/www/joruri/config/
$ cp -p /var/www/joruri/config/original/credentials/* /var/www/joruri/config/credentials/

設定ファイルを変更します。

$ vi /var/www/joruri/config/core.yml
---
production:
  title: Joruri  # サイト名を設定
  uri: http://joruri.example.com/  # サイトURLを設定
---

credentialsの設定ファイルを出力します。

$ EDITOR="vi" ./bin/rails credentials:edit --environment production

credentialsに保存されたことを確認します。

$ ./bin/rails credentials:show --environment production

SMTP設定をします。
※その他のSMTP設定は環境に応じて適切に設定してください。

$ vi /var/www/joruri/config/smtp.yml
---
openssl_verify_mode: none  # コメントアウトを外す
---

データベースを作成します。

$ bundle exec rake db:create db:schema:load db:migrate RAILS_ENV=production

初期データを登録します。

[空サイトを登録する場合]
$ bundle exec rake db:seed RAILS_ENV=production SITE_NAME="Joruri" SITE_URL="http://joruri.example.com/"

初期データの登録を確認します。

$ psql joruri_production -c "select * from cms_sites"

nginxの設定ファイルを生成します。

$ bundle exec rake joruri:configure RAILS_ENV=production

cronを登録します。

$ bundle exec whenever --update-crontab
$ crontab -l

13.サーバーの設定

rootユーザーに変更します。

$ su -

Joruriのnginx設定ファイルへリンクします。

# ln -s /var/www/joruri/config/nginx/nginx.conf /etc/nginx/conf.d/joruri.conf

デフォルトのnginx設定ファイルをリネームします。

# mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.org

ログローテートを設定します。

# cp /var/www/joruri/config/samples/logrotate /etc/logrotate.d/joruri_logrotate

サーバー再起動用のcronを登録します。

# cp /var/www/joruri/config/samples/reload_servers.sh /root/. && chmod 755 /root/reload_servers.sh
# cd /var/www/joruri; bundle exec whenever --load-file=config/schedule_root.rb --update-crontab

14.サーバーの起動

postfixを起動します。

# systemctl start postfix && systemctl enable postfix
# systemctl status postfix

postgresqlを起動します。

# systemctl start postgresql-15 && systemctl enable postgresql-15
# systemctl status postgresql-15

nginxを起動します。

# systemctl start nginx && systemctl enable nginx
# systemctl status nginx

nginxの起動ファイルを確認します。

# more /etc/systemd/system/multi-user.target.wants/nginx.service

PrivateTmp=trueと記述されている場合は、falseに変更します。

# vi /etc/systemd/system/multi-user.target.wants/nginx.service
---
PrivateTmp=false #変更
---
# systemctl daemon-reload
# systemctl restart nginx

unicornを起動します。

# cp /var/www/joruri/config/samples/unicorn.service /usr/lib/systemd/system/joruri_unicorn.service
# systemctl start joruri_unicorn && systemctl enable joruri_unicorn
# systemctl status joruri_unicorn

delayed_jobを起動します。

# cp /var/www/joruri/config/samples/delayed_job.service /usr/lib/systemd/system/joruri_delayed_job.service
# systemctl start joruri_delayed_job && systemctl enable joruri_delayed_job
# systemctl status joruri_delayed_job

15.動作確認

インストールが完了しました。

  • 公開画面: http://joruri.example.com/

  • 管理画面: http://joruri.example.com/_system

  • 管理者(システム管理者)

    • ユーザーID: joruri
    • パスワード: joruri
Topへ