ubuntu 13.04 安裝 gitlab 5.3 版

英文原版 Debian 下安裝教程: python

https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/doc/install/installation.md mysql

ubuntu 與 Debian 仍是有點區別的,由於 ubuntu 默認安裝了 sudo/python,而且 gedit 編輯器用着比 vim 容易上手...因此就沒有安裝 sudo/python 和 vim 的的代碼了... nginx

如今開始... git

一. 軟件源安裝所需的軟件包

sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev

二. 編譯安裝 ruby 1.9.3

mkdir /tmp/ruby && cd /tmp/ruby
curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz
cd ruby-1.9.3-p392
./configure
make
sudo make install
sudo gem install bundler

三. 爲 gitlab 建立用戶

sudo adduser --disabled-login --gecos 'GitLab' git

四. 安裝 gitlab-shell

# 登陸第三步建立的 git 用戶
sudo su git

# 切換到 git 用戶的 home 目錄
cd /home/git

# 克隆 gitlab-shell
git clone https://github.com/gitlabhq/gitlab-shell.git

cd gitlab-shell

cp config.yml.example config.yml

# 編輯配置文件 config.ym 而且替換 gitlab_url
# 爲主機域名.例如 'http://domain.com/',本地局域網安裝的話默認localhost就行.
gedit config.yml

# 開始安裝.
./bin/install

五. 安裝數據庫

# 軟件源安裝 mysql 數據庫,過程當中會讓你輸入兩次 mysql root 用戶的密碼,牢記!
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

# 用 root 用戶登陸 mysql
mysql -u root -p

# 建立 gitlab 用戶,替換 密碼 爲你的數據庫 gitlab 用戶的密碼. 牢記.(注:前面的 mysql> 不用複製)
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '密碼';

# 建立 gitlabhq_production 數據庫
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

# 將 gitlabhq_production 數據庫的增刪改查 等權限賦予 gitlab 用戶
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

# 退出 mysql 數據庫
mysql> \q

# 嘗試用 gitlab 用戶鏈接 gitlabhq_production 數據庫,登陸成功(注:出現 mysql>)說明數據庫配置完成.
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production

六. 安裝 gitlab

# gitlab 要安裝到 git 用戶的 home 目錄下.
cd /home/git
# 克隆 gitlab 項目
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab

# 進入 gitlab 目錄
cd /home/git/gitlab

# 切換到 gitlab 的 5.3 分支.
sudo -u git -H git checkout 5-3-stable
cd /home/git/gitlab

# 複製 gitlab 的示例配置文件到指定目錄
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# 若是用的不是本地服務器,更改 localhost 爲 gitlab 的服務器域名
sudo -u git -H gedit config/gitlab.yml

# 確保當前用戶對 gitlab 的 log 和 tmp 文件有讀寫權限.
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/

# 建立一個我不認識的目錄...汗!
sudo -u git -H mkdir /home/git/gitlab-satellites

# 再建立兩個我不認識的目錄...而且確保 當前用戶對他有讀寫權限.
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX  tmp/pids/
sudo chmod -R u+rwX  tmp/sockets/

# 建立公共的上傳備份目錄,並確保當前用戶對其有讀寫權限.不然備份會失敗.
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX  public/uploads

# 複製示例配置文件到制定目錄
sudo -u git -H cp config/puma.rb.example config/puma.rb

# 找到其中有一行 # workers 2,去掉前面的 # 並將 2 改成 3.
sudo -u git -H gedit config/puma.rb

# 配置 gitlab 的全局設置.
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@localhost"
# 複製示例Mysql配置文件到指定目錄
sudo -u git cp config/database.yml.mysql config/database.yml
# 修改裏面的 root 爲 gitlab, 密碼爲建立的 gitlab mysql 用戶密碼
sudo gedit config/database.yml
# 安裝一個我不認識的東西...我沒臉翻譯了...大哥你仍是看原版教程吧
cd /home/git/gitlab
sudo gem install charlock_holmes --version '0.6.9.4'
sudo -u git -H bundle install --deployment --without development test postgres
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# 下載 gitlab 的 開始/中止 腳本,而且加入當前用戶的可執行權限.
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
# 添加 gitlab 的開機啓動
sudo update-rc.d gitlab defaults 21
# 檢查 gitlab 的狀態和環境配置是否正確.
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
# 啓動 gitlab
sudo service gitlab start
# 或者
sudo /etc/init.d/gitlab restart
# 再次檢查 gitlab 的狀態,若是所有綠色,說明 gitlab 配置成功.不知道爲何,我要運行這個命令兩次纔會全綠
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

七. 配置 Nginx

# 軟件源安裝Nginx
sudo apt-get install nginx
# 複製 gitlab 的示例配置到指定目錄
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
# 修改配置文件.更改其中的 YOUR_SERVER_FQDN 爲你的 gitlab 服務器全稱域名或者本機IP地址,修改 listen 爲 *:80
sudo gedit /etc/nginx/sites-available/gitlab
# 重啓 nginx 服務器
sudo service nginx restart
# 打開瀏覽器輸入本機 IP,用下面的用戶密碼登陸既可.
admin@local.host
5iveL!fe
相關文章
相關標籤/搜索