Skip to content

Latest commit

 

History

History
128 lines (83 loc) · 2.81 KB

dev_setup_guide.md

File metadata and controls

128 lines (83 loc) · 2.81 KB

Development Environment Setup Guide

Ubuntu

安裝必要系統套件

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

安裝 PhantomJS

安裝 Ruby

使用 rbenv

依照安裝指示:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

修改 ~/.bashrc

# ~/.bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

ruby-build plugin

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

重整 shell(開新的 Terminal 視窗),然後檢查 rbenv 指令:

type rbenv
#=> "rbenv is a function"

開始安裝 ruby:

rbenv install 2.3.1
rbenv global 2.3.1 # set as global

設置 gem 安裝設定

echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc
gem install bundler

安裝 nodejs 環境

參照:https://nodejs.org/en/download/package-manager/

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

安裝 CrawlerMaster 相依系統套件

sudo apt-get install libpq-dev imagemagick libmagickwand-dev libqt4-dev libqtwebkit-dev

安裝 Redis

sudo apt-get install redis-server
sudo service redis-server status # 看一下有沒有跑起來

sudo service redis-server start # optional,redis 沒有跑起來的話

設置專案

git clone https://github.com/colorgy/CrawlerMaster
cd CrawlerMaster

echo '
REDIS_URL=redis://localhost:6379/
REDIS_NAMESPACE=crawler_master
' >> .env

bundle install

cp config/database.yml.example config/database.yml
rake db:setup && rake db:migrate && rake db:seed

跑起開發環境

gem install foreman

foreman start -f Procfile.dev

就可以登入 http://localhost:3000/ 了,預設的登入帳密是 admin/password,由 db/seeds.rb 建立。

雜項

Rubocop

是 Ruby 的靜態語法檢查工具,有 Vim 平臺的 syntastic(neomake 比較順)、Atom 的 linter-rubocop 可以設置。

VSCode

Atom

NeoVim

參考資料

  1. https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04