因為之前一直都在用 viewgit 這套東西. 不過每次都要 SSH 進主機開專案比較麻煩. 所以就在之前的 VPS 主要裡的 Debian 上玩了一下 Gitlab. 順便記錄一下安裝情況..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 # 更新 apt-get update apt-get dist-upgrade # 準備 Gitlabhq apt-get install curl sudo curl https://raw.github.com/gitlabhq/gitlab-recipes/master/install/debian_ubuntu.sh | sh sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev sudo gem install charlock_holmes --version '0.6.8' sudo pip install pygments sudo gem install bundler # 切到主目錄繼續安裝 cd /home/gitlab sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab cd gitlab # 這次用上了 MySQL 而不是 SQLite mysql -u root -p CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; exit; # 設定 Database 連線資料 sudo -u gitlab cp config/database.yml.example config/database.yml vim config/database.yml change the password # 安裝 Bundle 和 資料庫 sudo -u gitlab -H bundle install --without development test --deployment sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production # 放置提交後的 post-receive 鉤子 sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive sudo chmod g+rwx /home/git/.gitolite sudo usermod -g git gitlab # 最後進行環境測試.如全部都綠了就等於安裝成功 sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production # 最後打開任務隊列 和 配置 unicorn sudo -u gitlab ./resque.sh sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb # 安裝前面的 WebServer 以 proxy 方式傳到後方的 unicorn sudo apt-get install nginx sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/ sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab # 刪除原先的 Apache WebServer 改由 Nginx 作 Web apt-get remove apache2 /etc/init.d/nginx restart # 設定開機時執行的 Script sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/ sudo chmod +x /etc/init.d/gitlab sudo update-rc.d gitlab defaults # 預設的帳號和密碼 Login Email: [email protected] Login Password: 5iveL!fe # 解決 520 bad gateway 和配置 nginx # 完成後最後在新視窗再試一次 vim config/unicron.rb timeout 300 vim /etc/nginx/sites-enabled/gitlab server { listen 80; server_name _; } /etc/init.d/gitlab restart /etc/init.d/nginx restart # 修正 projects/new 的 localhost 名稱 vim config/gitlab.yml git_host: host: [IP] /etc/init.d/gitlab restart # 錯誤 /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) # 解決 locale -a vim /etc/locale.gen remove comment on en_US.UTF-8 sudo locale-gen locale -a # 錯誤 configure: error: no acceptable C compiler found in $PATH # 解決 apt-get install gcc 回答 n # 錯誤 debconf: DbDriver "config": could not open /var/cache/debconf/config.dat # 解決 mkdir /var/cache/debconf