Tags

, , , ,

Setting Up Ruby, rbenv and Rails

$ sudo apt-get update
$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

# Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL or exec -l $SHELL 

$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ exec $SHELL or exec -l $SHELL  ## To restart your shell

$ git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash

# install Ruby version 2.2.2
$ rbenv install 2.2.2
$ rbenv install 2.1.0

# Sets a local application-specific Ruby version by writing the version name to a .ruby-version file in the current project directory.
$ vim .ruby-version
2.1.0
or by using $ rbenv local 2.1.0

# Lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version.
$ rbenv versions
  system
* 2.1.0(set by /home/artheman/.rbenv/version)
  2.1.5
  2.2.2 

# Displays the currently active Ruby version. same as "ruby -v"
$ rbenv version
2.1.0

# Sets the global version of Ruby to be used in all shells
$ rbenv global 2.2.2

$ echo "gem: --no-ri --no-rdoc" > ~/.gemrc
$ gem install bundler
$ gem install rails
# Run this command after you install a new version of Ruby, or install a gem that provides commands.
$ rbenv rehash
$ rails -v

Setting Up MySQL

sudo apt-get install mysql-server mysql-client libmysqlclient-dev
# Next you'll prompted to enter your root password and you need to take note of it.
# To verify if the mysql service is running.
$ service mysql status or /etc/init.d/mysql status
mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-06-20 00:35:05 PHT; 4min 50s ago
 Main PID: 18896 (mysqld_safe)
   CGroup: /system.slice/mysql.service
           ├─18896 /bin/sh /usr/bin/mysqld_safe
           └─19243 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --s...

##Installing the libmysqlclient-dev gives you the necessary files to compile the mysql2 gem which is what Rails will use to connect to MySQL when you setup your Rails app.
If you want to install phpymyadmin, kindly check the links below.

References:
https://github.com/rbenv/rbenv
https://sudogem.wordpress.com/2012/08/26/install-mysql-and-phpmyadmin-on-ubuntu/

Advertisements