顯示具有 ruby 標籤的文章。 顯示所有文章
顯示具有 ruby 標籤的文章。 顯示所有文章

2013/06/02

Redhat 安裝 Gitlabhq [Old]

這是舊的筆記,請前往:
http://zx-1986.blogspot.com/2012/03/setup-gitlab-in-rhel-6.html

this note was out of date! please check the update version:
http://zx-1986.blogspot.com/2012/03/setup-gitlab-in-rhel-6.html

作業系統:RHEL 6.0 i386

cd /opt 

wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm && rpm -i *.rpm

yum groupinstall "Development Tools" # thanks for http://dejant.blogspot.com
yum install libxml2-devel libxslt-devel # thanks for http://dejant.blogspot.com
yum install git libxml2 libxslt sqlite sqlite-devel openssl zlib mysql++-devel mysql++ readline-devel compat-readline5 readline libcurl libcurl-devel libstdc++ libstdc++-devel libstdc++-docs compat-libstdc++-33

yum install python-pip
pip-python install pygments
# yum install python-setuptools
# easy_install pygments

adduser gitlabhq
passwd gitlabhq
visudo
#  gitlabhq    ALL=(ALL)    NOPASSWD: ALL

sudo bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# using sudo for multi-users installed!
# logout, then login as root again

rvm install 1.9.2  
rvm --default use 1.9.2
ruby --version

echo "gem: --no-rdoc --no-ri" > ~/.gemrc
gem update --system  
gem install bundler

echo $rvm_path/src/$(rvm tools strings) 
rvm @global gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/$(rvm tools strings)
exit

su - gitlabhq
ssh-keygen -t rsa

sudo yum install gitosis

sudo adduser -r -s /bin/sh -c 'git version control' -U -m git
sudo usermod -a -G git gitlabhq
sudo usermod -a -G rvm gitlabhq

sudo -H -u git gitosis-init < /home/gitlabhq/.ssh/id_rsa.pub

sudo chmod 755 /home/git
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

cd ~
git clone https://github.com/gitlabhq/gitlabhq.git

cd gitlabhq
vim Gemfile # :%s/git:/https:/g
vim Gemfile.lock # :%s/git:/https:/g

sudo su -

cd /home/gitlabhq/gitlabhq
bundle install # run the "bundle install" as "root" to avoid the permission issue at first time

cd /usr/local/rvm/gems/ruby-1.9.2-p290/bundler/gems
mv ./* /tmp

exit

bundle install # run the "bundle install" as "gitlabhq" to make sure all gems in gitlabhq/ grant to "gitlabhq"
bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production

vim config/gitosis.yml  # 檢查內容與路徑
rails s -e production # 啟動測試服務器

測試網址
http://localhost:3000

預設的帳號密碼
admin@local.host / 5iveL!fe

# 設定 Nginx

sudo su -
yum remove httpd
gem install passenger
passenger-install-nginx-module

# 選擇 1. Yes: download, compile and install Nginx for me. (recommended)
# passenger-install-nginx-module 會自動下載并編譯安裝 Nginx,預設裝到 /opt/nginx

vim /opt/nginx/conf/nginx.conf

---
user gitlabhq;
 
server {
  listen 80;
  server_name YOUR_IP_ADDRESS;
  root /home/gitlabhq/gitlabhq/public;
  passenger_enabled on;
}
---

/opt/nginx/sbin/nginx # start Nginx server
/opt/nginx/sbin/nginx -s stop # stop Nginx server

Reference:
http://isitruby19.com/linecache19
https://github.com/carlhuda/bundler/issues/1356
https://github.com/mark-moseley/linecache/issues/8
https://github.com/gitlabhq/gitlabhq/issues/66
https://github.com/gitlabhq/gitlabhq/issues/34
https://github.com/gitlabhq/gitlabhq/issues/84
https://github.com/gitlabhq/gitlabhq/issues/141

2012/07/06

Guard Livereload

apt-get install mpdcron
apt-get install libreadline-dev
apt-get install google-chrome-stable

Chrome Extension
http://download.livereload.com/2.0.8/LiveReload.crx

rvm install 1.9.3
rvm use 1.9.3 --default

gem install rails
gem install bundler
gem install em-websocket
gem install guard
gem install guard-livereload

rails new TEST
cd TEST
vim Gemfile 加入 gem 'guard' 和 gem 'rb-readline'
bundle exec guard init livereload
guard start

https://github.com/mockko/livereload/issues/91
http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
http://stackoverflow.com/questions/9340497/cannot-load-such-file-readline-loaderror-when-running-heroku-create-stack

2012/04/18

使用 Octopress 寫 Blog

http://jekyllbootstrap.com/
http://ruhoh.com/
http://orgmode.org/worg/org-tutorials/org-jekyll.html
https://github.com/imathis/octopress/wiki

Jekyll

Jekyll is a simple, blog aware, static site generator. It takes a template directory (representing the raw form of a website), runs it through Textile or Markdown and Liquid converters, and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.

https://github.com/mojombo/jekyll/wiki
http://orgmode.org/worg/org-tutorials/org-jekyll.html

Jekyll-Bootstrap

Octopress
Octopress 可以看成是一個 blog 書寫工具,它將你書寫的 blog 內容加工成靜態網頁。

[安裝 Ruby]
http://zx-1986.blogspot.com/2011/10/rvm.html

http://octopress.org/docs/deploying/github/
http://octopress.org/docs/deploying/heroku/

Enter the read/write url for your repository: git@github.com:zx1986/zx1986.github.com.git

http://markdown.tw/
http://octopress.org/docs/
http://zespia.tw/blog/2012/01/14/hello-octopress/
http://blog.lyhdev.com/2011/10/octopress-github-markdown.html
http://killtw.k2ds.net/blog/2011/10/29/how-to-install-rails/

2012/04/06

RVM - Ruby Version Manager

[安裝 rvm]
# 注意:使用 root 身份安裝的 rvm 是 system wide 的!
sudo su -

apt-get remove --purge ruby
apt-get remove --purge gem

apt-get install git autoconf patch curl bash wget

curl -L get.rvm.io | bash -s stable
usermod -a -G rvm YOUR_ACCOUNT

exit
logout
login

rvm notes

# ZSH 4.3.15 is buggy with RVM (2012/03)

[安裝 Ruby]
rvm install 1.8.6
rvm install 1.9.3

# rvm alias create default ruby-1.9.3
rvm --default use 1.9.3

ruby --version
which ruby
which gem

rvm help
rvm list
rvm list known
[使用 gemset]
rvm gemdir # 顯示 gems 資料夾

rvm gemset name # 查詢當前所用 gemset 的名稱
rvm gemset list # 查詢所有的 gemset
rvm gemset use NAME # 切換到指定的 gemset

rvm gemset create foo # 建立一個叫 foo 的 gemset 集合

rvm use 1.9.3@foo # 切換到 Ruby 1.9.3 搭配 foo 這個 gemset 的環境
rvm list # 查看 Ruby 1.9.3 的 foo 內有哪些 gems
rvm install rails # 在 Ruby 1.9.3 的 foo 內安裝 rails

rvm use 1.9.3@global # 切換回 Ruby 1.9.3 default 的 gemset 環境
rvm list # 查看 default 的 gemset 內有哪些 gems

rvm gemset export backup.gems # 將當前的 gems 備份
rvm gemset import backup.gems # 將 backup.gems 倒回來

# global gemset(~/.rvm/gemsets/global.gems)
# default gemset(~/.rvm/gemsets/default.gems)
# 這兩個 gemset 有點特殊,而且兩個其實不盡相同。
# global 會被 "added" 到每個用 rvm 安裝的 ruby
# default 會被 "included" 到每個新建的 gemset

[rvmrc]

rvmrc 是 rvm 的 runtime configuration,可以依據作用範圍的不同做區分。

系統範圍的:/etc/rvmrc
使用者範圍的:~/.rvmrc
專案範圍的:.rvmrc

組合技:
rvm --create --rvmrc 1.9.3@project
# 搭配 Ruby 1.9.3 建立一個叫 project 的 gemset,並 use 它,並幫它建立一個 .rvmrc

MRI:Matz's Ruby Interpreter(Matz 的 Ruby 直譯器)
p.s. Matz 是發明 Ruby 語言的日本程式設計師 Yukihiro Matsumoto 的昵稱。

Reference:
http://sirupsen.com/get-started-right-with-rvm/
http://beginrescueend.com
http://beginrescueend.com/rvm/install
http://beginrescueend.com/rvm/basics

2011/10/24

套件管理員

Python:pip
easy_install 或 setuptools 或 ez_setup.py
使用 easy_install 安裝起來放在 site-packages 的 *.egg 類似 Java 的 *.jar

PHP:Pear

Ruby:RubyGems

Perl:CPAN(Comprehensive Perl Archive Network)

R:CRAN

Node.js:npm

Ubuntu:apt-get、dpkg

Redhat:yum

Mac:homebrew

Reference:
01. http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html

2011/09/25

Ruby On Rails 環境架設

【使用 apt-get 的安裝流程】

#在 Ubuntu 底下架設 Ruby On Rails + Apache 2 + MySQL 環境

安裝所需套件:
sudo apt-get install ruby rails rubygems rake

sudo apt-get install apache2
sudo apt-get install libapache2-mod-ruby

sudo apt-get install mysql-server 
sudo apt-get install libdbi-ruby libdbd-mysql-ruby

sudo apt-get install vim-rails
sudo apt-get install libfcgi-dev

開啓 Apache rewrite 模組:
sudo a2enmod rewrite
sudo service apache2 restart

RubyGems 指令:
sudo gem list # 列出已安裝套件
sudo gem list -r 套件名稱 # 搜尋套件
sudo gem install 套件名稱 # 安裝套件
sudo gem uninstall 套件名稱 # 移除套件

ERROR: gem update --system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using Debian official repositories.
If you really know what you are doing, you can still update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment variable, but please remember that this is completely unsupported by Debian.

使用 apt-get 或 aptitude 安裝的 RubyGems,Gems 套件預設會放在:
/var/lib/gems/1.8/gems/



【使用 tarball 的安裝流程】

下載 Ruby 原始檔
解壓縮並切換到原始檔資料夾
執行 configure
執行 make
執行 make install

下載 Gem 原始檔
解壓縮並切換到原始檔資料夾
執行 ruby setup.rb

使用 tarball 安裝,Gem 的執行檔預設會是:
/usr/bin/gem1.8

使用 tarball 安裝,Gems 套件預設會放在:
/usr/lib/ruby/gems/1.8



【ruby-full 搭配 Gem tarball】
sudo apt-get install ruby-full

下載 Gem 原始檔
解壓縮並切換到原始檔資料夾
執行 ruby setup.rb

使用 tarball 安裝,Gem 的執行檔預設會是:
/usr/bin/gem1.8

使用 tarball 安裝,Gems 套件預設會放在:
/usr/lib/ruby/gems/1.8



【XDite 推薦的安裝流程】

http://github.com/zx1986/rails-nginx-passenger-ubuntu
http://killtw.k2ds.net/blog/2011/10/29/how-to-install-rails



Reference:
01. https://help.ubuntu.com/community/RubyOnRails
02. http://blog.xdite.net/?p=1754
03. http://blog.xdite.net/?p=1807
04. http://github.com/jnstq/rails-nginx-passenger-ubuntu
05. http://www.cc.ntu.edu.tw/chinese/epaper/20070620_1007.htm
06. http://packages.ubuntu.com/hardy/ruby-full
07. http://blog.longwin.com.tw/2008/11/ruby-on-rails-linux-environment-build-2008/
08. http://ihower.tw/rails3/installation.html