shirasagiをCentOS7以外で動かす(Docker、AlmaLinux、ubuntu、arm64環境)

先日、Dockerを使ってAlmaLinuxをインストールしました。この時、ホストはarm64のubuntu22.04でした。

https://minokamo.tokyo/2022/08/28/5200/

本日は、このAlmaLinuxにshirasagiをインストールします。shirasagiは株式会社ウェブチップスが開発したオープンソースソフトウェアです。Ruby on Railsで開発されており、CMSやグループウェアとして使用できます。また、インストール環境はCentOS7が推奨されています。

http://ss-proj.org/

それでは作業をしていきましょう。最初にAlmaLinuxのコンテナを立ち上げます。

docker run -d -p 3000:3000 --privileged --name shirasagi イメージID /sbin/init

コンテナに入ってAlmaLinuxのバージョンを確認します。更新は最初にしておきます。

docker exec -it shirasagi bash
cat /etc/almalinux-release
dnf update

AlmaLinux release 8.6 (Sky Tiger)

ここからは、公式のインストール手順を参考にして進みます。

https://shirasagi.github.io/installation/manual.html

ただし、簡単インストールが出来ません。また、コマンドを変更するところが多数出てきます。コンテナ内ではSELlinux、 Firewalldは存在しませんでしたのでセキュリティ設定はしません。

★パッケージのダウンロード

dnf install scl-utils
dnf install wget git

AlmaLinuxなのでcentos-release-sclはインストールできませんでした。コンテナ内ではclearコマンドが無かったので「Ctrl+L」を使用しました。ImageMagickのインストールではエラーが発生しました。

dnf install ImageMagick ImageMagick-devel

No match for argument: ImageMagick
No match for argument: ImageMagick-devel
Error: Unable to find a match: ImageMagick ImageMagick-devel

これを解決するために、powertoolsを有効にします。

dnf config-manager --set-enabled powertools

このコマンドを実行すると、エラーが表示されますが、次のディレクトリにリポジトリのファイルが作成されます。

No such command: config-manager. Please use /usr/bin/dnf –help
It could be a DNF plugin command, try: “dnf install 'dnf-command(config-manager)'"

cd /etc/yum.repos.d/
vi almalinux-powertools.repo

エディタで開いてpowertoolsを有効にします。

enable=1

更新してImageMagickのインストールを試みるが、同じエラーが発生しました。

dnf update
dnf install ImageMagick ImageMagick-devel

この問題は、EPELリポジトリをインストールすることで解決できました。

dnf install epel-release
dnf install ImageMagick ImageMagick-devel

devtoolset-10はRHEL7、CentOS7でサポートされていてインストールできないので、devtoolset-11を試すが失敗。色々調査した結果、次をインストールすることと同様らしい。

dnf install gcc-toolset-11

★MongoDBのインストール

Official installation
http://docs.mongodb.org/manual/installation/

shirasagi公式ではMongoDBのバージョンが4.4であったが、バージョン6をインストールすることにします。リポジトリを手動で追加します。新規でリポジトリのファイルを作成します。

vi /etc/yum.repos.d/mongodb-org-6.0.repo

・記述内容
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/aarch64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

CPUアーキテクチャがarm64ですので、x86_64をaarch64に変更します。

MongoDBのインストール完了後に状態を確認しましたが、停止しているので起動します。

dnf install --enablerepo=mongodb-org-6.0 mongodb-org
systemctl start mongod
systemctl enable mongod

★Ruby(RVM) のインストール

curlコマンドの3行目にsudoがありますが、rootで実行しているので取り除いてコマンドを実行します。

curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile
rvm install 2.7.5 --disable-binary
rvm use 2.7.5 --default

★shirasagiのダウンロード

git clone -b stable https://github.com/shirasagi/shirasagi /var/www/shirasagi

★Webサーバーの起動

devtoolset-10の所は変更してコマンドを入力します。

cd /var/www/shirasagi
cp -n config/samples/*.{rb,yml} config/
source /opt/rh/gcc-toolset-11/enable
bundle install --without development test

grpc 1.38.0とsassc 2.3.0のインストールでマシンがフリーズしたかと思うくらい遅かったのですが、待っていれば正常に終了します。しかし、Bundlerが古いと表示されたので指示に従います。さらにBundlerをrootとして実行してはいけないと表示されたので対処します。

[DEPRECATED] The --without flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use bundle config set without 'development test', and stop using this flag
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.32). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.2.32.

gem install bundler:2.2.32
dnf install sudo
rake unicorn:start

しかし、エラーが発生したので表示されている対処方法を試みます。

ERROR: It looks like you’re trying to use Nokogiri as a precompiled native gem on a system with glibc < 2.17:

/lib64/libm.so.6: version `GLIBC_2.29′ not found (required by /usr/local/rvm/gems/ruby-2.7.5/gems/nokogiri-1.13.6-aarch64-linux/lib/nokogiri/2.7/nokogiri.so) – /usr/local/rvm/gems/ruby-2.7.5/gems/nokogiri-1.13.6-aarch64-linux/lib/nokogiri/2.7/nokogiri.so

If that’s the case, then please install Nokogiri via the ruby platform gem:
gem install nokogiri –platform=ruby
or:
bundle config set force_ruby_platform true

Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help.

rake aborted!
LoadError: /lib64/libm.so.6: version `GLIBC_2.29′ not found (required by /usr/local/rvm/gems/ruby-2.7.5/gems/nokogiri-1.13.6-aarch64-linux/lib/nokogiri/2.7/nokogiri.so) – /usr/local/rvm/gems/ruby-2.7.5/gems/nokogiri-1.13.6-aarch64-linux/lib/nokogiri/2.7/nokogiri.so

gem install nokogiri --platform=ruby
bundle config set force_ruby_platform true

その後再び、rakeコマンドを入力します。

rake unicorn:start

Could not find libv8-node-15.14.0.1, nokogiri-1.13.6 in any of the sources
Run bundle install to install missing gems.

今度は不足しているものがあるみたいなので対処します。

gem install libv8-node
gem install nokogiri

その後、バンドルコマンドを再度実行します。

sudo bundle install --without development test

Bundle complete! 124 Gemfile dependencies, 209 gems now installed.
Gems in the groups 'development’ and 'test’ were not installed.
Use bundle info [gemname] to see where a bundled gem is installed.

nokogiri 1.13.6のインストールの時はマシンがフリーズしたかと思うくらい時間がかかりました。1時間くらいは見ておいた方がいいかもしれません。

rake unicorn:start

bundle exec unicorn_rails -c /var/www/shirasagi/config/unicorn.rb -E production -D

うまくいったようなのでブラウザでアクセスします。ホストとコンテナでファイヤーウォールは無効になっています。ただし、Oracle Cloudのセキュリティリストにはポート番号3000を追加して、トラフィックを許可しておきます。

http://150.136.164.12:3000/.mypage

ログイン画面が正常に表示されました。

★新規サイトの作成

shirasagiのホームディレクトリに切り替えます。

cd /var/www/shirasagi

データベースを削除して、新たに作成します。

rake db:drop
rake db:create_indexes

管理者を作成します。ここで作成したユーザーのメールアドレスとパスワードでログインできます。

rake ss:create_user data='{ name: "システム管理者", email: "sys@example.jp", password: "pass" }'

教育

Posted by admin