1. ホーム
  2. スクリプト・コラム
  3. ルビートピックス

Ruby on Railsのインストールに関する簡潔で迅速なガイド

2022-02-03 07:50:35

Ruby、Ruby Gems、およびRails実行環境を初めて使う開発者にとって、Ruby、Ruby Gems、およびRailsのインストールは問題になることがあります。
システム要件

まずOS環境を決定します。Windowsでの取得は推奨されていませんので、.NETを使用します。

  •     Mac OS X
  •     あらゆるLinuxディストリビューション(Ubuntu, CentOS, Redhat, ArchLinux ...)
  •     強い初心者はUbuntuを使って、無駄な苦労を省く!

以下のコードのうち、プレフィックスが$の部分は、コンソール(端末)下で実行する必要があることを示しています($の記号を除く)。
ステップ 0 - システムに必要なパッケージのインストール

[hadoop@cassandra01 hadoop-2.6.0-cdh5.7.0]$ mvn clean package -Pdist,native -DskipTests -Dtar
...
...
Downloading: https://repository.cloudera.com/content/repositories/snapshots/org/apache/maven/shared/maven-common-artifact-filters/ 1.0/maven-common-artifact-filters-1.0.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.0/maven-common-artifact- filters-1.0.pom
Downloading: https://repository.cloudera.com/content/repositories/cdh-releases-rcs/org/apache/maven/shared/maven-downloader/1.1/ maven-downloader-1.1.pom
Downloading: https://repository.cloudera.com/content/repositories/snapshots/org/apache/maven/shared/maven-downloader/1.1/maven- downloader-1.1.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-downloader/1.1/maven-downloader-1.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Apache Hadoop Main ................................. FAILURE [ 12.084 s]
[INFO] Apache Hadoop Project POM .......................... SKIPPED
[INFO] Apache Hadoop Annotations .......................... SKIPPED
[INFO] Apache Hadoop Assemblies ........................... SKIPPED
[INFO] Apache Hadoop Project Dist POM ..................... SKIPPED
[INFO] Apache Hadoop Maven Plugins ........................ SKIPPED
[INFO] Apache Hadoop MiniKDC .............................. SKIPPED
[INFO] Apache Hadoop Auth ................................. SKIPPED
[INFO] Apache Hadoop Auth Examples ........................ SKIPPED
[INFO] Apache Hadoop Common ............................... SKIPPED
[INFO] Apache Hadoop NFS .................................. SKIPPED
[INFO] Apache Hadoop KMS .................................. SKIPPED
[INFO] Apache Hadoop Common Project ....................... SKIPPED
[INFO] Apache Hadoop HDFS ................................. SKIPPED
[INFO] Apache Hadoop HttpFS ............................... SKIPPED
[INFO] Apache Hadoop HDFS BookKeeper Journal .............. SKIPPED
[INFO] Apache Hadoop HDFS-NFS ............................. SKIPPED
[INFO] Apache Hadoop HDFS Project ......................... SKIPPED
[INFO] hadoop-yarn ........................................ SKIPPED
[INFO] hadoop-yarn-api .................................... SKIPPED
[INFO] hadoop-yarn-common ................................. SKIPPED
[INFO] hadoop-yarn-server ................................. SKIPPED
[INFO] hadoop-yarn-server-common .......................... SKIPPED
[INFO] hadoop-yarn-server-nodemanager ..................... SKIPPED
[INFO] hadoop-yarn-server-web-proxy ....................... SKIPPED
[INFO] hadoop-yarn-server-applicationhistoryservice ....... SKIPPED
[INFO] hadoop-yarn-server-resourcemanager ................. SKIPPED
[INFO] hadoop-yarn-server-tests ........................... SKIPPED
[INFO] hadoop-yarn-client ................................. SKIPPED
[INFO] hadoop-yarn-applications ........................... SKIPPED
[INFO] hadoop-yarn-applications-distributedshell .......... SKIPPED
[INFO] hadoop-yarn-applications-unmanaged-am-launcher ..... SKIPPED
[INFO] hadoop-yarn-site ................................... SKIPPED
[INFO] hadoop-yarn-registry ............................... SKIPPED
[INFO] hadoop-yarn-project ................................ SKIPPED
[INFO] hadoop-mapreduce-client ............................ SKIPPED
[INFO] hadoop-mapreduce-client-core ....................... SKIPPED
[INFO] hadoop-mapreduce-client-common ..................... SKIPPED
[INFO] hadoop-mapreduce-client-shuffle .................... SKIPPED
[INFO] hadoop-mapreduce-client-app ........................ SKIPPED
[INFO] hadoop-mapreduce-client-hs ......................... SKIPPED
[INFO] hadoop-mapreduce-client-jobclient .................. SKIPPED
[INFO] hadoop-mapreduce-client-hs-plugins ................. SKIPPED
[INFO] hadoop-mapreduce-client-nativetask ................. SKIPPED
[INFO] Apache Hadoop MapReduce Examples ................... SKIPPED
[INFO] hadoop-mapreduce ................................... SKIPPED
[INFO] Apache Hadoop MapReduce Streaming .................. SKIPPED
[INFO] Apache Hadoop Distributed Copy ..................... SKIPPED
[INFO] Apache Hadoop Archives ............................. SKIPPED
[INFO] Apache Hadoop Archive Logs ......................... SKIPPED
[INFO] Apache Hadoop Rumen ................................ SKIPPED
[INFO] Apache Hadoop Gridmix .............................. SKIPPED
[INFO] Apache Hadoop Data Join ............................ SKIPPED
[INFO] Apache Hadoop Ant Tasks ............................ SKIPPED
[INFO] Apache Hadoop Extras ............................... SKIPPED
[INFO] Apache Hadoop Pipes ................................ SKIPPED
[INFO] Apache Hadoop OpenStack support .................... SKIPPED
[INFO] Apache Hadoop Amazon Web Services support .......... SKIPPED
[INFO] Apache Hadoop Azure support ........................ SKIPPED
[INFO] Apache Hadoop Client ............................... SKIPPED
[INFO] Apache Hadoop Mini-Cluster ......................... SKIPPED
[INFO] Apache Hadoop Scheduler Load Simulator ............. SKIPPED
[INFO] Apache Hadoop Tools Dist ........................... SKIPPED
[INFO] Apache Hadoop Tools ................................ SKIPPED
[INFO] Apache Hadoop Distribution ......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.223 s
[INFO] Finished at: 2018-08-16T15:11:48+08:00
[INFO] Final Memory: 77M/858M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process (default) on project hadoop-main: Execution default of goal org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process failed: Plugin org.apache.maven.plugins: maven-remote-resources-plugin:1.0 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins: maven-remote-resources-plugin:jar:1.0 -> org.apache.maven:maven-project:jar:2.0.5: Failed to read artifact descriptor for org.apache. maven:maven-project:jar:2.0.5: Could not transfer artifact org.apache.maven:maven-project:pom:2.0.5 from/to cdh.releases.repo (https:// repository.cloudera.com/cont

ステップ1 - RVMのインストール

RVMが何をするものかはここでは説明しませんので、後で理解してください。

# Check the last dependency to download before the error
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-downloader/1.1/maven-downloader-1.1.pom


# cd to the path corresponding to the package name in the local repository
[hadoop@cassandra01 1.0.5]$ cd ~/maven_repo/velocity/velocity/1.4/

# wget to download the above package, the download path is the above error link
[hadoop@cassandra01 1.4]$ wget https://repo.maven.apache.org/maven2/velocity/velocity/1.4/velocity-1.4.pom

# Go back to the compile window and compile again

この間、sudoの管理者パスワードを要求されたり、homebrew経由で依存関係を自動的にインストールしたり、RVMが正常にインストールされるまでしばらく待ちます。

その後、RVM環境をロードします(新しいTermalで行う必要はありません、自動的にリロードされます)。

$ source ~/.rvm/scripts/rvm



正しくインストールされていることを確認する

$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]



ステップ2 - RVMによるRuby環境のインストール

$ rvm install 2.0.0



ここでも長いダウンロード、コンパイル作業を待ち続け、それが終わるとRuby、Ruby Gemsがインストールされています。
ステップ3 - Rubyのバージョンを設定する

RVMをインストールしたら、次のコマンドを実行して、指定されたバージョンのRubyをシステムのデフォルトとして設定する必要があります。

$ rvm 2.0.0 --default



繰り返しますが、rvm install でそのバージョンをインストールしていれば、他のバージョン番号も使用可能です。

この時点で、それが正しいかどうかテストすることができます。

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]

$ gem -v
2.1.6

$ gem source -r https://rubygems.org/
$ gem source -a https://ruby.taobao.org



ステップ4 - Rails環境のインストール

上記の3つのステップでRuby環境がインストールされたので、次にRailsをインストールします。

$ gem install rails



次に、インストールが正しいかどうかをテストします。

$ rails -v
Rails 3.2.13



そして、Ruby, Railsの旅を始めましょう。
Rubyの世界へようこそ!
その他のリソース

https://github.com/huacnlee/init.d - 本番環境の迅速なインストールのための Ubuntu Server バッチスクリプト