GNU/Linux >> Linux Esercitazione >  >> Panels >> Panels

Come installare Ruby su Ubuntu 18.04

In questo post, ti mostreremo come installare Ruby su un VPS Ubuntu 18.04.

Ruby è un linguaggio di programmazione dinamico, open source e orientato agli oggetti con particolare attenzione alla semplicità e alla produttività. È meglio conosciuto per il suo utilizzo nel framework Ruby on Rails.

L'installazione di Ruby è un compito facile e non dovrebbe richiedere più di 10 minuti. Iniziamo con l'installazione.

Metodo 1:installazione di Ruby con RVM

Prima di iniziare, dovrai prima accedere al tuo server. Dovrai accedere come account root o come utente con privilegi sudo.

NOTA:  Questo metodo, sebbene non sia il più veloce, ti porterà l'ultima versione di Ruby (così come qualsiasi versione specifica) installata sul tuo server. Se la tua applicazione supporta una gamma più ampia di versioni di Ruby, l'installazione utilizzando il Metodo 2 (più avanti nel tutorial) potrebbe essere il modo migliore, poiché è più veloce.

RVM è uno strumento da riga di comando che ti aiuta a installare, gestire e lavorare con più versioni di Ruby.

I seguenti pacchetti sono necessari per installare Ruby con RVM e creare gemme Ruby sul tuo server Ubuntu. Esegui questo comando per installarli:

sudo apt-get install curl gnupg gnupg2 build-essential libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

Una volta installati questi pacchetti, installa le chiavi GPG RVM:

 sudo gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

L'output del comando sarà simile al seguente:

gpg: key 105BD0E739499BDB: 5 signatures not checked due to missing keys
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <[email protected]>" imported
gpg: key 3804BB82D39DC0E3: 103 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <[email protected]>" not changed
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1

Installa RVM eseguendo il comando seguente:

curl -sSL https://get.rvm.io | sudo bash -s stable

Una volta installato RVM, vedrai il seguente output:

Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: Signature made Thu 03 Jan 2019 04:01:48 PM CST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <[email protected]>" [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.7.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!
To start using RVM you need to run:
source /etc/profile.d/rvm.sh

Ora puoi installare l'ultima versione di Ruby con il seguente comando:

rvm install ruby
rvm --default use ruby

Il comando creerà Ruby dal sorgente e richiederà del tempo per essere completato. L'output sarà simile a questo:

ruby-2.6.0 - #extracting ruby-2.6.0 to /usr/local/rvm/src/ruby-2.6.0.....
ruby-2.6.0 - #configuring......................................................................
ruby-2.6.0 - #post-configuration..
ruby-2.6.0 - #compiling.............  ............................................................................
ruby-2.6.0 - #installing...............
ruby-2.6.0 - #making binaries executable..
Installed rubygems 3.0.1 is newer than 2.7.8 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.6.0 - #gemset created /usr/local/rvm/gems/ruby-2.6.0@global
ruby-2.6.0 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-2.6.0 - #generating global wrappers.......
ruby-2.6.0 - #gemset created /usr/local/rvm/gems/ruby-2.6.0
ruby-2.6.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.0 - #generating default wrappers.......
ruby-2.6.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

Verifica la versione di ruby ​​eseguendo il seguente comando:

ruby -v

Al momento della stesura di questo articolo, l'ultima versione di Ruby è la 2.6.0.

ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]

Puoi anche installare Bundler per poter gestire le dipendenze gem dell'applicazione:

gem install bundler --no-rdoc --no-ri

Se desideri installare una versione specifica di Ruby, utilizza questo formato per definire la versione che desideri installare:

rvm install ruby-X.X.X
rvm --default use ruby-X.X.X

Ad esempio, per installare Ruby versione 2.5.1 sul tuo server Ubuntu, il comando seguirà questo formato:

rvm install ruby-2.5.1
rvm --default use ruby-2.5.1

Metodo 2:installa Ruby con Apt

Il modo più semplice per installare Ruby è dal repository APT di Ubuntu.

Aggiorna gli elenchi dei pacchetti di Ubuntu per ottenere informazioni sulle versioni più recenti dei pacchetti e sulle loro dipendenze e installa Ruby utilizzando i seguenti comandi:

sudo apt-get update
sudo apt-get install ruby-full

Per verificare la versione di Ruby installata, esegui il seguente comando:

ruby -v

Al momento della stesura di questo articolo, il pacchetto ruby-full fornisce Ruby 2.5.1.

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

Congratulazioni, ora Ruby è installato sul tuo VPS Ubuntu 18.04.

Ovviamente, non devi installare Ruby su Ubuntu 18.04 se utilizzi uno dei nostri servizi di hosting VPS Ruby, nel qual caso puoi semplicemente chiedere ai nostri esperti amministratori Linux di installare Ruby su Ubuntu 18.04 per te. Sono disponibili 24 ore su 24, 7 giorni su 7 e si prenderanno immediatamente cura della tua richiesta.

PS. Se ti è piaciuto questo post su come installare Ruby su Ubuntu 18.04, condividilo con i tuoi amici sui social network usando le scorciatoie di condivisione qui sotto, o semplicemente lascia un commento nella sezione commenti. Grazie.


Panels
  1. Come installare Ruby su Ubuntu 20.04

  2. Come installare Ruby su Ubuntu 18.04

  3. Come installare R su Ubuntu 16.04

  4. Come installare Vai su Ubuntu 18.04

  5. Come installare Ruby su Ubuntu 18.04

Come installare Ruby su Ubuntu

Come installare WPScan su Ubuntu 14.04

Come installare Ruby on Rails su Ubuntu 16.04

Come installare Ruby on Rails su Ubuntu 20.04 LTS

Come installare Ruby on Rails su Ubuntu 20.04 con RVM

Come installare Ruby su Ubuntu 18.04