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

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

Ubuntu 安裝 Gitlabhq [Failed]

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

it does NOT WORK! please check the update version:
http://zx-1986.blogspot.com/2012/03/setup-gitlab-in-rhel-6.html

在 Ubuntu 11.04 Server 安裝 Gitlabhq

THIS IS NOT WORK!

su -
export http_proxy="your_proxy"
export https_proxy="your_proxy"
apt-get update && apt-get upgrade

# 設定 Ruby 環境

apt-get install git-core curl gcc checkinstall make build-essential 
apt-get install libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline5-dev libc6-dev libssl-dev libmysql++-dev zlib1g-dev
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
source /etc/bash.bashrc
rvm install 1.9.2
rvm install 1.9.3
rvm --default use 1.9.2
gem update --system
echo "gem: --no-rdoc --no-ri" > ~/.gemrc

注意:使用的是 rvm 管控下的 Ruby 1.9.2 與其搭配的 rubygems

# 安裝 Gitosis

apt-get install git gitosis
adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
ssh-keygen -t rsa
sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub
chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
# 安裝 Gitlabhq
cd /opt
pip install pygments
apt-get install python-setuptools
easy_install pygments
apt-get install libsqlite3-dev
gem install bundler
git clone https://github.com/gitlabhq/gitlabhq.git
cd gitlabhq
vim Gemfile # :%s/git:/https:/g
vim Gemfile.lock # :%s/git:/https:/g
echo $rvm_path/src/$(rvm tools strings) 
rvm @global gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/$(rvm tools strings)
bundle install
bundle exec rake db:setup RAILS_ENV=production
bundle exec rake db:seed_fu RAILS_ENV=production
vim /opt/gitlabhq/config/gitosis.yml  # 檢查內容與路徑
rails s -e production # 啟動測試服務器
測試網址 http://localhost:3000 預設的帳號密碼 admin@local.host / 5iveL!fe # 安裝 Nginx
apt-get autoremove apache2*
dpkg --purge apache2*
apt-get install nginx
gem install passenger
passenger-install-nginx-module

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

===
user root;

server {
  listen 80;
  server_name gitlabhq;
  root /opt/gitlabhq/public;
  passenger_enabled on;
}
===

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/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