Skip to content

Environment Setup and Deployment

Daniel Coo edited this page Feb 25, 2016 · 1 revision

Setting up theCourseForum - Newest

  • Git (sudo apt-get install git)
  • Your choice of editor (vim, nano, emacs, Sublime Text)
  • RVM
  • Ruby 2.2.3
  • Rails 4.2.4
  • MySQL

Terminal Proficiency

You will be doing a lot of the setup work in the Terminal (known as the shell or bash) prompt. For Ubuntu, for example, you can open a terminal prompt with Ctrl-Alt-T. For Macs, just search for the Terminal app. Please read the wiki page here: [Terminal Proficiency] (https://github.com/thecourseforum/theCourseForum/wiki/Sysadmin-Tools-(Terminal-Proficiency))

Package Control

See [here] (https://github.com/thecourseforum/theCourseForum/wiki/Packaging-Managers) for a more detailed overview of what a package manager is. For Linux users, you will have one installed already. For Mac, I highly recommend Homebrew to manage these dependencies. Many of these installations can be done by substituting apt-get with brew, i.e. brew install git.

Git

You will need git to pull and push code. sudo apt-get install git will get that installed for you. To pull the code use git clone https://github.com/thecourseforum/theCourseForum and a folder called theCourseForum will be created in the current working directory with our code content.

Editor Choice

vim/nano/emacs

It is up to you how to develop and write code. vim is one of the most ubiquitous options out there, found on almost all servers - but the learning curve is rather steep. See [here] (https://github.com/thecourseforum/theCourseForum/wiki/Terminal-Text-Editors) for more details. If you're more comfortable with these text editors (or want to get better at them), feel free to use them! Personally, I use vim only on the server for hotfixes/small changes, and Sublime otherwise.

Sublime Text

Your choice on either Sublime Text 2 or 3 - I recommend installing from their repository from instructions [Sublime Text 3 Beta] (http://www.webupd8.org/2013/07/sublime-text-3-ubuntu-ppa-now-available.html) or [Sublime Text 2 Stable] (https://launchpad.net/~webupd8team/+archive/ubuntu/sublime-text-2). For Sublime Text 2, just follow the Sublime Text 3 instructions but use the right ppa URL.

Install the Sublime Package Control (manager) as well [here] (https://packagecontrol.io/installation).

RVM

To adequately manage different Ruby versions, we use RVM (Ruby Version Manager). Full installation instructions can be found [here] (https://rvm.io/rvm/install) but I will provide them here as well.

Ensure you are downloading from the correct repository with:

  • gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 to add the RVM website
  • sudo apt-get install curl to ensure curl (used for downloading) is installed.
  • \curl -sSL https://get.rvm.io | bash To download the RVM install script
  • You may have to reload your terminal window (close terminal and restart it) or with /bin/bash --login
  • rvm install 2.2.3 to install Ruby 2.2.3
  • We use Bundler to manage our gems (Ruby libraries), so make sure gem install bundler is run as well.

MySQL Server

Installing

MySQL is our choice of database for theCourseForum. Proficiency with the MySQL command line is an important skill that will come in handy no matter where you go.

sudo apt-get install mysql-server will install both the client and server. For the root password for the database, it is recommended that you choose one that is different from your normal account password, but it's not terribly important what it is as long as you remember it. You will use this password to configure Rails to talk to your database

Setup

mysql -u root -p will open the mysql client - here you will type SQL to interface with the database. Create the development database with CREATE DATABASE thecourseforum_development;

Alternatively, you can cd into the project directory, and run rake db:create to create your databases. Either is sufficient.

To actually load the database with data, see one of the senior team members for access to the database, found [here] (http://phpmyadmin.thecourseforum.com). Download the database from thecourseforum_beta

Installing gems

Gems (ruby libraries) are what make Ruby great. Rails is a popular Ruby gem for web development, for example, and there are many other great gems out there too. If you want to implement something - google to see if a gem for it already exists!

cd into the project directory and run bundle install. Depending on the current configuration of your system, various gems may fail. Others may take a long time (nokogiri, libv8, mysql2 come to mind). If you run into various errors, you may need to update your base system.

mysql2

You may need sudo apt-get install libmysqlclient-dev to install this gem.

json

You may need sudo apt-get install libgmp3-dev for this one.

Others

Let someone know if some other gem doesn't work (or Google is your best friend)

That should get you setup!

Setting up theCourseForum - Newer

  • Git
  • Sublime
  • RVM
  • Ruby
  • Rails
  • MySQL
  • Xcode (Mac only)
  • Homebrew (Mac only)

Mac

  1. Go to installrails.com and follow the tutorial
  2. Install mysql by following this stackoverflow answer

TroubleShooting

  • The infamous MySQL socket error. See here

Linux (Ubuntu/Debian)

  1. Install sublime 3
  2. Go to http://railsapps.github.io/installrubyonrails-ubuntu.html and follow the tutorial. When you get to 'Databases for Rails', install the mysql database
    $ sudo apt-get install libmysqlclient-dev
    $ sudo apt-get install mysql-server
  • Give it a password for the root user, will reference it as $DB_PW

Windows

Dual boot guide for Windows 10
Dual boot guide for Windows 8.1

Setting up the local instance

$ cd theCourseForum/
$ bundle install

$ cp config/database.yml.skel config/database.yml

  • Add $DB_PW to password fields in database.yml
  • Verify that the socket field has a correct path!!!

$ cp config/initializers/devise.rb.example config/initializers/devise.rb

  • Add config.secret_key = "mysecretkey1234" to devise.rb (this is already in the example)

$ touch config/initializers/secret_token.rb

  • Add TheCourseForum::Application.config.secret_key_base = "othersecretkey1234"

$ cp config/application.yml.example config/application.yml

  • Needed for global environment variables from figaro gem

Set up Your Database

  • Log onto phpmyadmin -> http://phpmyadmin.thecourseforum.com/
  • Expand thecourse tab on the left
  • Expand beta and click the thecourse_beta database
  • Click Export and to download thecourse_beta.sql
  • Repeat these steps for the thecourse_production database
  • You should now have thecourse_beta.sql and thecourse_production.sql in your ~/Downloads/ directory

Verify that mysql is installed $ mysql --version
mysql Ver 14.14 Distrib 5.6.26, for osx10.8 (x86_64) using EditLine wrapper

Log in to mysql and set up the databases $ cd ~/Downloads/
$ mysql -u root -p
[Enter your password]
$ show databases;
If you already have thecourseforum_development and/or thecourseforum_production databases, drop them
Else, skip these next two commands
$ drop database thecourseforum_development;
$ drop database thecourseforum_production;

$ create database thecourseforum_development;
$ create database thecourseforum_production;

$ use thecourseforum_production;
$ source thecourseforum_production.sql

$ use thecourseforum_development;
$ source thecourseforum_beta.sql

Exit mysql ctrl-D

Start the server!

$ rails s





Setting up theCourseForum - Older

Git

Mac

git-scm.com/download/mac

Ubuntu/Debian

$ sudo apt-get install git

Rails

Install curl

Note: Macs should have this already

$ sudo apt-get install curl

Install RVM (Ruby Version Manager)

$ \curl -L https://get.rvm.io | bash -s stable

$ source ~/.rvm/scripts/rvm

  • Macs can skip this?

$ rvm requirements

Mac’s may need to install/update Xcode

Mac’s also need to install Homebrew and other dependencies

  • $ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

  • $ brew install libtool libxslt libksba penssl

Install Ruby

$ rvm install 2.0.0

$ rvm use 2.0.0

Install Rails

$ gem install rails -v 4.0.0

Edit ~/.bashrc (Ubuntu/Debian)

cd ~/

nano .bashrc

  • or use your favorite text editor

Add this line to the file somewhere:

  • [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
  • Makes it so that you don’t need to run source ~/.rvm/scripts/rvm each time you start up a terminal

MySQL

Mac OS X

$ brew install mysql

OR Install through the package?

Ubuntu/Debian

$ sudo apt-get install libmysqlclient-dev

$ sudo apt-get install mysql-server

  • Give it a password for the root user, will reference it as $DB_PW

Other Dependencies

Ubuntu/Debian

$ sudo apt-get install libqtwebkit-dev

  • Needed for capybara-webkit gem for testing

Set up the Git Repository

$ git clone https://github.com/thecourseforum/theCourseForum

$ cd theCourseForum

$ git checkout development

  • Switches to development branch

Set up the local instance

$ bundle install

$ cp config/database.yml.skel config/database.yml

  • Add $DB_PW to password fields in database.yml

$ cp config/initializers/devise.rb.example config/initializers/devise.rb

  • Add config.secret_key = "mysecretkey1234" to devise.rb

$ touch config/initializers/secret_token.rb

  • Add TheCourseForum::Application.config.secret_key_base = "othersecretkey1234"

$ cp config/application.yml.example config/application.yml

  • Needed for global environment variables from figaro gem

$ rake db:setup

Start the server!

$ rails s

Clone this wiki locally