Skip to content

Installing Catarse on Ubuntu 12.04 VMWare

lvxn0va edited this page Feb 7, 2013 · 15 revisions

Here's a complete breakdown of Installing Catarse on Ubuntu 12.04 using a VMWare Fusion 5 on Mac OSX Lion. This installation has been tested a few times with several blank VMWare Ubuntu VM's while creating this post. This may or may not work on other versions of Ubuntu or Debian. Your mileage will vary.

NOTE: You need to know some linux commands and be familiar with Rails. Google is your friend!

Download and Install Ubuntu

  • Download a Ubuntu 12.04 i386 or amd64 Desktop .iso from http://releases.ubuntu.com/precise/ For this tutorial I used ubuntu-12.04.1-desktop-i386.iso

  • Install and fire up your Ubuntu 12.04 VM in VMWare - I've used the basic settings: 1GB RAM and 20GB Hardrive. I'd share the desktop and home folder too.

  • Login to the Ubuntu desktop and open Terminal

  • Choose Edit | "Profile Preferences"

  • Click Title and Command Tab at top and check
    Run command as login shell

  • Close Profile Preferences

Install RUBY The Hard Way Or The Easy Way

  • If you'd like to make things really easy and get started almost immediately, In your VMWare Ubuntu session open a web browser and go to: http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/

  • Right-click the link on the page to download the rails-installer.sh script and follow the instructions.

  • You can also manually install Ruby and the files you need by following the longer tutorial on that page.

  • When the script is finished installing be sure to make sure rvm is running in your terminal window:
    source ~/.rvm/scripts/rvm

Install and Configure Catarse

  • From your user root, create a new railsApps directory and change into it
    cd
    mkdir railsApps
    cd railsApps

Choose if you are going to just develop and deploy to heroku OR if you plan on sharing your development files publicly on GitHub

  • If you are jsut going to Develop your app locally and then deploy to heroku:

  • Download Catarse:
    git clone https://github.com/danielweinmann/catarse.git (for master)

  • If you wish to share your code updates publicly on Github and possibly push change suggestions to catarse:

  • Fork the main catarse repo to your github account

  • Download Catarse from your fork:
    git clone https://github.com/YOUR_USERNAME/catarse.git (for master)

  • Enter into Catarse directory:
    cd catarse (or alternate branch)

  • A notice will come up: Do you wish to trust this .rvmrc file? (~/catarse/.rvmrc)
    Choose cancel for right now

  • You are going to pdate the catarse gemset to use ruby 1.9.3
    sudo nano .rvmrc

  • Inside the file, change the gemset from 1.9.2 to 1.9.3
    Ctrl-x and enter to save and exit

  • Create Catarse Gemset:
    rvm gemset create catarse

The Postgresql Database

  • You're going to clone the database settings file
    cd config

  • Choose yes to accept the .rvmrc file

  • Copy database settings to new .yml file:
    cp database.sample.yml database.yml

  • Edit the database.yml to look like:

    development:
    adapter: postgresql
    encoding: utf-8
    database: catarse_development
    pool: 5
    username: catarse
    password: catarse host: localhost
    port: 5432

Ctrl-x andd ENTER to save and exit

  • Change back to the catarse root directory
    cd ..

  • Install the PostgreSQL Database and gem:
    sudo apt-get install postgresql pgadmin3 libpq-dev postgresql-server-dev-all postgresql-contrib xsel
    gem install pg

  • We'll need to add the default postgres user password or else we can't access psql
    sudo -u postgres psql postgres

  • At the psql prompt, change the password
    \password postgres

  • Create a password and retype it
    Ctrl-D to exit psql

Bundle and create user/database

  • Time to bundle all of our gems in the Gemfile but first lets fix some errors that will come up with Curb and rmagick:
    sudo apt-get install libcurl4-gnutls-dev graphicsmagick-libmagick-dev-compat libmagickwand-dev libmagickcore-dev
    gem install curb
    gem install rmagick

  • Make sure that the preious gems installed correctly then create your bundle your Gems!
    bundle install

  • Create PostgreSQL Database User:
    sudo -u postgres createuser -D -P catarse

  • Choose Yes to add as SuperUser

  • Enter new password 2X to match databsae.yml above:
    catarse

  • Create Database:
    rake db:create
    sudo -u postgres createdb -O your-current-catarse-username your-database (catarse_development)

  • Change DB Password Hash:
    sudo nano /etc/postgresql/9.1/main/pg_hba.conf

  • Change this line only:
    local all all peer To this:
    local all all md5

  • Restart PostgreSQL:
    sudo service postgresql restart

  • Check your postgresql login:
    psql -d your-database -U your-current-catarse-username -W
    Enter PASSWORD
    If you are logged into the PostgreSQL prompt, you are connected!

  • Quit PostgreSQL:
    type:\q

Update Bundle and Start Catarse

Fix the 'block_in_non_options error

  • Open Gemfile
    sudo nano Gemfile

  • Change the Shoulda gem to read:
    gem 'shoulda', :require => false
    Ctrl-x and Enter to save and exit

  • Add the following to the top of the spec/spec_helper.rb file:
    require 'shoulda

  • Update the Catarse Gem bundle: bundle update

  • Migrate the database:
    bundle exec rake db:migrate

  • Seed your database, Catarse uses the db/seeds.rb file to bootstrap the categories and notification types. To create your own categories go ahead and change this file. After that you can run:
    bundle exec rake db:seed

  • Save your work
    git add .
    `git commit -am "Catarse starting config"

  • (outdated) : Start the Catarse application (outdated) bundle exec unicorn -p 3000
    When "worker=0 ready" appears, you can leave the Terminal window open

  • "we removed the unicorn from the bundle in the last version. We are considering going back to it. For now just type rails s to start the Catarse application "

  • Open a browser to:
    http://localhost:3000

+++++++++++++++++++++ CURRENTLY EDITING! USER BEWARE ++++++++++++++++++++++++++++++++++++++++++

Signup and Sign in

  • Sign up and Sign in using Google or Facebook
    Grant permissions when presented

  • Go back to VMWare, and in the running terminal, STOP your current unicorn session:
    Type ctrl-c

  • Start the Rails Console
    Type rails c

  • Choose your newly created user:
    Type u = User.first

  • Make your new login the Admin User:
    Type u.update_attribute :admin, true

  • Exit Rails Console:
    Type exit

  • Restart catarse:
    rails s
    When "worker=0 ready" appears you can refresh your browser

  • When you're ready, go to:
    http://localhost:3000/en/projects/new

  • Create your new project
    Be sure to have a Vimeo video link available
    Submit your finished project

The above should get you started using Catarse locally, and in as minimal time as possible.

Deploy To Heroku

Package everything up

  • Precompile your assets RAILS_ENV=production bundle exec rake assets:precompile

  • Add the files to Git
    git add public/assets
    git commit -m "vendor compiled assets"

  • Package your gems
    bundle package --all
    bundle install

  • Add the files to Git
    git add .
    git commit -m "Bundle Package"

Get set with Heroku

Create SSH keys

  • In order to push to Heroku, you have to setup some ssh keys cd ~/.ssh

  • Backup your current keys if you have any - List files in ~/.ssh folder
    ls -la

  • Check for the is_rsa file - If you have, continue below. If you don't, skip to **Create New SSH Key**

  • Make a backup folder mk_dir key_backup

  • Copy your current key to the backup folder
    cp is_rsa* key_backup

  • Delete your old key
    rm id_rsa*

  • Create a new SSH Key
    ssh-keygen -t rsa -C "MY_EMAIL@ADDRESS"
    Enter for file location
    Create passphrase
    Enter new passphrase

  • Create the pbcopy function on your Linux machine.

  • Create a new ~./bash_aliases file
    sudo nano ~/.bash_aliases

  • Enter the following into the ~/.bash_aliases file
    alias pbcopy='xsel --clipboard --input'
    alias pbpaste='xsel --clipboard --output'
    Ctrl-x and Enter to save and exit

  • Activate the ~/.bash_aliases file in the current bash session
    source ~/.bash_aliases

  • Copy new Key to clipboard
    pbcopy < ~/.ssh/id_rsa.pub

  • If you haven't already, sign up for a free account at http://heroku.com

  • To Enter new public_key in Heroku, Login to your Heroku acct and go to Account Profile at Top Right

  • Scroll to the SSH Keys Section

  • Click to put the cursor in Add Shh Key.. field

  • Paste the SSH key from the clipboard into the field

  • Click Add key button

Create the Heroku app.

  • Download and install the Heroku Toolbelt from toolbelt.heroku.com
    Type cd
    wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

  • Change back into your catarse folder
    cd ~/railsApps/catarse

  • Login to your local Heroku toolbelt from the command line: heroku login

  • create your catarse app
    heroku create

  • Make a note of your new apps web address!

  • Create the free postgresql database on heroku
    heroku addons:add heroku-postgresql:dev

  • Push to Heroku
    git push heroku master

  • In the popup, enter your SSH passphrase you created earlier.

  • Migrate your database
    heroku run rake db:migrate

  • Seed your database with the categories and configurations in seeds.rb
    heroku run rake db:seed

  • Open a browser to your heroku app http address

  • Check Heroku logs for errors
    heroku logs

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  • Now when you develop, be sure to create branches and merge your changes with Git.
    git add .
    git commit -am "Blah blah blah"

  • Post your merges to your Github Crowdplaces fork master branch:
    git push upstream master

  • When you are ready to publish your customizations to heroku for the world to see do:
    git push heroku master

This tutorial has not been tested in other flavors of *nix..CentOS, fedora, redHat and even Debian will all need their own modifications so be prepared!

Thanks to Daniel, Diogob, devton josemar, Jorge Guberte and Relsi Hur Maron and everyone else for their incredible contributions to the Catarse project and for their work on the getting started documentation. If anything doesn't work..reply in the forum and I'll change it up..OR feel free to edit this page with what works