rvm のインストール
この部分はrvm の公式手順に従って、インストールを進めていきます。
まずは、gpg key のインストール。
# gpg key のインストール
gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
rvm でruby のstable のバージョンをインストールしたかったので、今回はstable のバージョンをインストールしていきましょう
# rvm install
curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri 15 Jan 2021 06:46:22 PM UTC
gpg: using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.12.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
* First you need to add all users that will be using rvm to 'rvm' group,
and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
* To start using RVM you need to run `source /etc/profile.d/rvm.sh`
in all your open shell windows, in rare cases you need to reopen all shell windows.
* Please do NOT forget to add your users to the rvm group.
The installer no longer auto-adds root or users to the rvm group. Admins must do this.
Also, please note that group memberships are ONLY evaluated at login time.
This means that users must log out then back in before group membership takes effect!
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
そして、この説明に書いてある通り、rvm を使えるようにするために、/etc/profile.d/rvm.sh をsource で有効化していきます。
source /etc/profile.d/rvm.sh
libyaml-devel がないとエラーが出ると記載があったので、crb のrepo を明示的に指定してあげて、インストールしていきます。
# コマンド
dnf install --enablerepo=crb libyaml-devel
# 出力結果
AlmaLinux 9 - CRB 1.9 MB/s | 2.9 MB 00:01
Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64 941 B/s | 2.5 kB 00:02
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Installing:
libyaml-devel x86_64 0.2.5-7.el9 crb 141 k
Transaction Summary
=============================================================================================================================================================
Install 1 Package
Total download size: 141 k
Installed size: 1.0 M
Is this ok [y/N]: y
そして、rvm install でrubyの3.2.2 をインストールしていきます。現状、ruby が一つもインストールされていないので、rvm list コマンドを実行しても何もないよというのが返却されます。
rvm install で configure とcompile を一緒にやってくれるみたいです。
だいたいソースインストールするときとかは、configure でMakefile 作って、make して、compile というのが常套手段だとは思うのですが、便利です。ちょっと長いですが。
# コマンド
rvm install ruby-3.2.2
# 叩いた時の挙動
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/9/x86_64/ruby-3.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, libffi-devel, libtool, patch, readline-devel, ruby, sqlite-devel............................-
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-3.2.2, this may take a while depending on your cpu(s)...
ruby-3.2.2 - #downloading ruby-3.2.2, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19.5M 100 19.5M 0 0 14.5M 0 0:00:01 0:00:01 --:--:-- 14.5M
No checksum for downloaded archive, recording checksum in user configuration.
ruby-3.2.2 - #extracting ruby-3.2.2 to /usr/local/rvm/src/ruby-3.2.2.....
ruby-3.2.2 - #configuring..................................................................
ruby-3.2.2 - #post-configuration..
ruby-3.2.2 - #compiling...............................................................................................................................
ruby-3.2.2 - #installing.....................
ruby-3.2.2 - #making binaries executable...
Installed rubygems 3.4.10 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.2.2 - #gemset created /usr/local/rvm/gems/ruby-3.2.2@global
ruby-3.2.2 - #importing gemset /usr/local/rvm/gemsets/global.gems...........................................................
ruby-3.2.2 - #generating global wrappers........
ruby-3.2.2 - #gemset created /usr/local/rvm/gems/ruby-3.2.2
ruby-3.2.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.2.2 - #generating default wrappers........
ruby-3.2.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.2.2 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
よし、インストールできている!!
rvm list
=* ruby-3.2.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
passenger とnginx をインストール
passenger と nginx をインストールしていく前に、gem でpassenger インストールします。そうしないとエラーが出ます。
# コマンド
passenger-install-nginx-module
# 出力結果
Ignoring debug-1.7.1 because its extensions are not built. Try: gem pristine debug --version 1.7.1
Ignoring executable-hooks-1.7.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.7.1
Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
Ignoring rbs-2.8.2 because its extensions are not built. Try: gem pristine rbs --version 2.8.2
/usr/share/rubygems/rubygems.rb:278:in `find_spec_for_exe': can't find gem passenger (>= 0.a) with executable passenger-install-nginx-module (Gem::GemNotFoundException)
from /usr/share/rubygems/rubygems.rb:297:in `activate_bin_path'
from /usr/local/bin/passenger-install-nginx-module:25:in `<main>'
なので、gem installします
gem install passenger
インストールできたら、もう一回チャレンジします。module install するのも時間かかります。(このコマンド実行したけど、非対話式で実行するのもありだったな)
# コマンド
passenger-install-nginx-module
#出力結果(成功したらこんな感じです)
--------------------------------------------
Nginx with Passenger support was successfully installed.
Please edit your Nginx configuration file (probably /opt/nginx/conf/nginx.conf),
and set the passenger_root and passenger_ruby configuration options in the
'http' block, like this:
http {
...
passenger_root /usr/local/rvm/gems/ruby-3.2.2/gems/passenger-6.0.20;
passenger_ruby /usr/local/rvm/gems/ruby-3.2.2/wrappers/ruby;
...
}
After you (re)start Nginx, you are ready to deploy any number of web
applications on Nginx.
Press ENTER to continue.
--------------------------------------------
Deploying a web application
To learn how to deploy a web app on Passenger, please follow the deployment
guide:
https://www.phusionpassenger.com/library/deploy/nginx/deploy/
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com
Passenger® is a registered trademark of Phusion Holding B.V.
そして、後はnginx.conf に上に記載されていることを確認して、passenger を使えるようにするために、passenger_enabled on の設定にしてください。そして、nginx を起動させてあげましょう!
もし、systemd を使いたいということであれば、別途systemd ファイルを作成する必要があるので、別の記事でそれは書きます!
まとめ
rvm とか nginx passenger とかってあまり触れないので、インストールすらちょっと抵抗があったのですが、案外さらっといったので(記事のおかげ)、もうちょっと設定工夫できるように頑張っていきます。
参考にしたサイト
Qiita 記事
rvm 公式
nginx passenger ソースインストール方法