在本文中,我们将学习如何设置和配置Ruby on Rails,它是开发人员使用的最流行的堆栈应用程序,通常用于创建站点和Web应用程序。Ruby是一种编程语言,程序员可以结合使用Rails开发框架来使应用程序开发变得快速而简单。
“ RVM”(Ruby版本管理器)是用于安装Ruby和Rails的命令行工具,它还为使用Ruby on Rails进行应用程序开发提供了良好的环境,还可以提供多个Ruby环境。
我们需要具有非root用户的Ubuntu 16.04安装机器。
使用RVM安装Ruby on Rails的最简单方法是以非root用户身份运行以下命令,并会提示您输入常规密码。
我们将使用“ gpg”命令联系公共键服务器,并请求给定ID的关联键。
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 Output: gpg: directory `/home/ubuntu/.gnupg' created gpg: new configuration file `/home/ubuntu/.gnupg/gpg.conf' created gpg: WARNING: options in `/home/ubuntu/.gnupg/gpg.conf' are not yet active durin g this run gpg: keyring `/home/ubuntu/.gnupg/secring.gpg' created gpg: keyring `/home/ubuntu/.gnupg/pubring.gpg' created gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net gpg: /home/ubuntu/.gnupg/trustdb.gpg: trustdb created gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
现在我们将在/ tmp文件夹中下载RVM脚本
$ cd /tmp
以下是下载用于安装RVM的脚本的命令。
$ \curl -sSL https://get.rvm.io -o rvm.sh
下载脚本后,我们将运行以下命令进行安装,该命令将安装稳定的Rails版本并安装最新的稳定版本的Ruby。
$ cat rvm.sh | bash -s stable --rails Output: Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc gpg: Signature made Tuesday 29 March 2016 07:19:47 PM IST using RSA key ID BF04FF17 gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" 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: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17 GPG verified '/home/ubuntu/.rvm/archives/rvm-1.27.0.tgz' Adding rvm PATH line to /home/ubuntu/.profile /home/ubuntu/.mkshrc /home/ubuntu/.bashrc /home/ubuntu/.zshrc. Adding rvm loading line to /home/ubuntu/.profile /home/ubuntu/.bash_profile /home/ubuntu/.zlogin. Installation of RVM in /home/ubuntu/.rvm/ is almost complete: * To start using RVM you need to run `source /home/ubuntu/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows. # ubuntu, # # Thank you for using RVM! # We sincerely hope that RVM helps to make your life easier and more enjoyable!!! # # ~Wayne, Michal & team. In case of problems: https://rvm.io/help and https://twitter.com/rvm_io rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/] Searching for binary rubies, this might take some time. Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.3.0.tar.bz2 Checking requirements for ubuntu. Installing requirements for ubuntu. Updating system.... Installing required packages: libsqlite3-dev, sqlite3, libgmp-dev, libtool, pkg-config........ Requirements installation successful. ruby-2.3.0 - #configure ruby-2.3.0 - #download % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 24.8M 100 24.8M 0 0 670k 0 0:00:37 0:00:37 --:--:-- 911k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.3.0 - #validate archive ruby-2.3.0 - #extract ;ruby-2.3.0 - #validate binary ruby-2.3.0 - #setup ruby-2.3.0 - #gemset created /home/ubuntu/.rvm/gems/ruby-2.3.0@global ruby-2.3.0 - #importing gemset /home/ubuntu/.rvm/gemsets/global.gems.............................. ruby-2.3.0 - #generating global wrappers........ ruby-2.3.0 - #gemset created /home/ubuntu/.rvm/gems/ruby-2.3.0 ruby-2.3.0 - #importing gemsetfile /home/ubuntu/.rvm/gemsets/default.gems evaluated to empty gem list ruby-2.3.0 - #generating default wrappers........ Creating alias default for ruby-2.3.0... .. .. Installing ri documentation for rails-5.0.0.1 Done installing documentation for i18n, thread_safe, tzinfo, concurrent-ruby, activesupport, rack, rack-test, mini_portile2, nokogiri, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubis, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mime-types-data, mime-types, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 72 seconds 36 gems installed * To start using RVM you need to run `source /home/ubuntu/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows. * To start using rails you need to run `rails new <project_dir>`.
安装完成后,我们需要运行以下命令以添加环境变量和路径
$ source /home/ubuntu/.rvm/scripts/rvm
现在我们将检查安装,以下是用于检查安装的命令。
$ rvm Output: = rvm * https://rvm.io/ * http s://github.com/rvm/rvm/ == DESCRIPTION: RVM is the Ruby enVironment Manager (rvm). It manages Ruby application environments and enables switching between them. == Installation …… …… Action documentation available with 'rvm help action-name': alias autolibs cleanup config-get cron current debug disk-usage do docs fetch fix-permissions gemdir gemset gemset/copy get group implode info install list migrate mount notes osx-ssl-certs patchset pkg prepare reinstall remove repair requirements reset rubygems rvmrc rvmrc/to rvmrc/warning snapshot srcdir tools uninstall upgrade use user wrapper Other topics of documentation available with 'rvm help topic': alt color upgrade-notes For additional information please visit RVM's documentation website: https://rvm.io/ If you still cannot find an answer to your question, find 'wayneeseguin', 'mpapis', 'richo', 'lemoinem' or 'rys' in #rvm on irc.freenode.net: http://webchat.freenode.net/?channels=rvm
如果我们要安装特定版本的Ruby以满足您的要求,则必须使用以下命令。
列出可用版本
$ rvm list known
要安装特定版本
$ rvm install version_no
列出已安装的版本
$ rvm list
切换到特定的安装版本
$ rvm use ruby_version
由于Rails是gem,因此我们也可以安装特定版本以满足我们的环境,gem是要安装的命令,我们可以使用以下命令来执行安装。
列出Rails的有效版本
$ gem search ‘rails$’ –all
要安装特定版本
$ gem install rails –v version_no
创建宝石集
$ rvm gemset create new_gemset_name
用新的gemset指定Ruby版本。
$ rvm ruby_version@new_gemset_name
由于某些Rails功能取决于JavaScript运行时环境,因此我们需要安装Node.js。
以下是安装Node.js的命令
$ cd /tmp $ \curl -sSL https://deb.nodesource.com/setup_6.x -o nodejs.sh $ less nodejs.sh $ cat /tmp/nodejs.sh | sudo -E bash – Output: ## Installing the NodeSource Node.js v6.x repo... ## Populating apt-get cache... + apt-get update Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://deb.kamailio.org/kamailio jessie InRelease Hit:3 http://security.ubuntu.com/ubuntu xenial-security InRelease Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease Reading package lists... Done W: http://deb.kamailio.org/kamailio/dists/jessie/InRelease: Signature by key E79ACECB87D8DCD23A20AD2FFB40D3E6508EA4C8 uses weak digest algorithm (SHA1) … .. Fetched 6,595 B in 9s (680 B/s) Reading package lists... Done W: http://deb.kamailio.org/kamailio/dists/jessie/InRelease: Signature by key E79ACECB87D8DCD23A20AD2FFB40D3E6508EA4C8 uses weak digest algorithm (SHA1) ## Run `apt-get install nodejs` (as root) to install Node.js v6.x and npm
现在我们可以使用apt-get命令获取Node.js
$ sudo apt-get install nodejs Output: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: nodejs 0 upgraded, 1 newly installed, 0 to remove and 107 not upgraded. Need to get 10.1 MB of archives. After this operation, 50.7 MB of additional disk space will be used. Get:1 https://deb.nodesource.com/node_6.x xenial/main amd64 nodejs amd64 6.8.1-1nodesource1~xenial1 [10.1 MB] Fetched 10.1 MB in 37s (272 kB/s) Selecting previously unselected package nodejs. (Reading database ... 70921 files and directories currently installed.) Preparing to unpack .../nodejs_6.8.1-1nodesource1~xenial1_amd64.deb ... Unpacking nodejs (6.8.1-1nodesource1~xenial1) ... Processing triggers for man-db (2.7.5-1) ... Setting up nodejs (6.8.1-1nodesource1~xenial1) ...
在本文结束之后,您将能够通过具有多个Ruby环境的JavaScript运行时来设置和配置RVM以安装Ruby和Rails。
问题内容: 我是Jenkins CI的新手。我在远程Jenkins中以及在shell下执行时安装RVM。 我收到以下错误。 这是什么意思?我不知道 请帮我。 更新: 我尝试下面的脚本,但仍然出现错误: 错误: Jenkins构建外壳无法检测RVM,gemset和gem。我该怎么办? 更新2: 因此詹金斯无法检测到红宝石。 我没有使用任何jenkins插件,而只是从Build-> Execute s
本文向大家介绍如何在Ubuntu 16.04上使用'rbenv'设置和配置Ruby on Rails,包括了如何在Ubuntu 16.04上使用'rbenv'设置和配置Ruby on Rails的使用技巧和注意事项,需要的朋友参考一下 在本文中,我们将学习如何设置和配置Ruby on Rails,它是开发人员用来创建站点和Web应用程序的最流行的堆栈应用程序。Ruby是一种编程语言,程序员可以将它
我在使用appium运行java mobile automation测试用例时遇到了这个错误 处理命令时发生未知的服务器端错误。原始错误:packageAndLaunchActivityFromManifest失败。原始错误:找不到aapt请用Android SDK根目录路径设置ANDROID_HOME环境变量。(警告:服务器未提供任何stacktrace信息) 配置: IntelliJ IDE-
但是如果我让Spring Boot自动配置JOOQ,那么我应该把这个设置放在哪里呢? 基本的Spring Boot配置似乎只支持在中设置,如jooq-spring-boot-example所示。 我尝试将放入中,但这对SQL没有任何影响。 有没有办法自定义Spring boot JOOQ配置,而不必自己配置JOOQ? 我使用的是SpringBoot 2.1.7.Release和JOOQ 3.11.
我有两个环境来设置我的API,所以我有生产和开发。我首先需要的是找到一种方法来自动完成这一任务,例如,在运行时,不发送任何参数(-d)应用程序找到了一种方法来识别环境,但我没有找到任何方法来完成这一任务。 所以我看了一个教程,在同样有一个方法放了一个环境变量,并定义了我的application.properties。所以在下面的步骤中: > 我在我的应用程序中定义了3个文件,application
本文向大家介绍如何在Ubuntu 16.04上设置和配置Jekyll开发站点,包括了如何在Ubuntu 16.04上设置和配置Jekyll开发站点的使用技巧和注意事项,需要的朋友参考一下 在本文中,我们将学习如何设置和配置Jekyll开发站点。Jekyll在数据库驱动的站点中提供了内容管理系统(CMS)的优势,并具有性能和安全性。它也称为博客意识,具有处理按日期组织的内容的功能。它特别适合于离线工