Skip to content

Latest commit

 

History

History
248 lines (156 loc) · 7.39 KB

INSTALL.md

File metadata and controls

248 lines (156 loc) · 7.39 KB
  1. Install for development
  2. Install for testing
  3. Install for production
  4. Configuration options

Install for development

For installation using Vagrant, see doc/development/vagrant.md.

Install basic ruby environment

(Tested with ruby 2.1, at least ruby 2.0)

Debian-based system

sudo apt-get install ruby ruby-dev rake mysql-server mysql-client
libmysqld-dev git make libssl-dev g++ sphinxsearch graphicsmagick
Debian stable

On Debian stable 9, mysql has been replaced by MariaDB. To set up the environment, we need to replace libmysql-dev by libmariadb-dev.

sudo apt-get install ruby ruby-dev rake mysql-server mysql-client
libmariadb-dev git make libssl-dev g++ sphinxsearch graphicsmagick

Depending on what you are running, you might need to install git-core instead of git. You might also need libopenssl-ruby. If installing using bundler, you may need libmysqlclient-dev and libsqlite3-dev.

Redhat-based system

yum install ruby ruby-devel rubygem-rake mysql-server mysql-devel git gcc make
ImageMagick

OSX system

This install will assume you are using a Ruby versioning tool such as rbenv and zsh. These tools are by no means OSX dependent. You can replace .zshrc with .bash_profile if you use bash.

If you don't have git:

brew install git

Once you have git:

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.zshrc
rbenv versions

Once you have the code, run this from inside of the source directory. Ruby 2.1.5 should work here, but you can customize it if need be.

rbenv install 2.1.5
gem install bundler

Now for the app dependencies

brew install mysql graphicsmagick sphinx --with-mysql

To run MySQL

mysqld

If you run into any problems bundling with bundle install (a few steps down), make sure that you are up to date with XCode and that you have installed the command line developer tools. XCode can be updated from the App Store. You may need to open XCode after updating to accept the licenses. If you need the command line tools, run the following.

xcode-select --install

Checkout the codebase

git clone ssh://[email protected]:riseuplabs/crabgrass.git
or
git clone https://0xacab.org/riseuplabs/crabgrass.git

Alternately, do a shallow clone. This will only check out a copy of the most recent version.

git clone --depth 1 https://0xacab.org/riseuplabs/crabgrass.git

Install bundler

If you don't yet have bundler, install it now as root.

sudo gem install bundler

Alternatively you can install bundler with your package manager.

Install rails and required gems

cd crabgrass
bundle install

Create the database

This will also set up your test database. Prior to running the rake db:create command, you will need to set up the crabgrass_development and crabgrass_test databases and configure them in the database.yml file according to your mysql or mariadb set up. In addition, I needed to set up my databases with mariadb with utf8 encoding. See here.

cp config/database.yml.example config/database.yml
rake db:create
rake db:schema:load
rake cg:convert_to_unicode
rake db:fixtures:load

Run the server

BOOST=1 bundle exec rails server

Connect to the web application from your browser:

http://localhost:3000
login: blue
password: blue

The first request will be slow because the server compiles the stylesheets for the themes. See doc/development/* for more notes on development.

Install for testing

Install additional gems needed for testing

sudo RAILS_ENV=test bundle install

Create testing database

If you haven't run rake db:create already.

sudo mysqladmin create crabgrass_test
cd crabgrass
rake db:test:prepare

Run tests:

bundle exec rake

Install for production

setup the environment

Many of the following commands require RAILS_ENV to be set. You can do so for the current session with export RAILS_ENV=production

You may also want to add this to your shell environment by default.

Alternatively you can prefix the commands involving rails or rake like this

RAILS_ENV=production bundle exec rails c

install prerequisites

Download and install ruby, rubygems, rails, and mysql the same way as in the 'install for development' instructions.

Then:

apt-get install sphinxsearch
bundle install

sphinxsearch is not technically required, but crabgrass runs 100 times faster with it installed.

setup the database

create the database:

sudo mysqladmin create crabgrass

create database.yml:

cp config/database.yml.example config/database.yml

edit config/database.yml:

username: crabgrass
password: your_password

set the permissions:

> mysql --user root -p
mysql> use crabgrass;
mysql> grant all on crabgrass.* to crabgrass@localhost identified by 'your_password';
mysql> flush privileges;
mysql> quit

initialize the database:

rake cg:convert_to_unicode
rake db:schema:load

A note about unicode support: running rake db:create does not correctly create a fully unicode compatible database. To make non-latin languages work, you need the rake cg:convert_to_unicode task. It only needs to be run once, but is non-destructive, so it can be run anytime.

compile assets

We use the rails assets pipeline for compiling javascript. In order to do so this should be run after deploying a new version of the codebase:

rake assets:precompile

See the asset pipeline docs for more information and alternative strategies: http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

For css we rely on our custom theming mechanism. In order to install the css files for images please run

rake cg:images:update_css

configure apache

See doc/deployment/apache for information on deploying for production with apache.

set up crontab

There are a bunch of maintenance tasks that need to be updated regularly. The easiest way to do this is to set up a crontab. The gem whatever will install one for you from the schedule.rb config file.

whenever --update-crontab -f config/misc/schedule.rb

start delayed job daemon

We index updated documents in sphinx using delayed job. (ts-delayed-delta to be exact). Run delayed job as a daemon so it can start the jobs:

script/delayed_job start

You may want to symlink script/delayed_job from your start script directory such as /etc/init.d

Configuration options

All the options that you might want to change live in three places:

  1. config/database.yml
  2. config/secret.txt
  3. config/crabgrass/crabgrass-.yml.

See config/crabgrass/README for more information.