aliyun服務器ubuntu 14.04安裝gitlab 7.x筆記

1.(root)更換apt-get源 新建文件source.list,內容以下:mysql

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
cp /etc/apt/sources.list /etc/apt/sources.list.bak
cp sources.list /etc/apt/sources.list
apt-get update

2.(root)安裝必要的包nginx

apt-get install -y cmake 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 vim

3.(root)安裝郵件服務器,默認設置便可git

apt-get install -y postfix

4.(root)安裝ruby,使用阿里的ruby源能夠節省下載時間 這裏有修改,主要是ruby-1.9.3對commit刪除記錄有版本問題,會引起http500問題github

mkdir /tmp/ruby && cd /tmp/ruby
curl --progress https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.2.tar.gz | tar xz
cd ruby-2.1.2
./configure
make
make install

5.(root)安裝bundler,爲了節省時間,記得更換ruby源redis

gem sources --remove http://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install bundler

6.(root)添加git用戶sql

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

備註:從root用戶切換到git用戶:su git,退出git返回到root用戶:exitshell

7.(git)安裝gitlab-shell數據庫

su git
cd /home/git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout v2.0.1
cp config.yml.example config.yml

只須要修改gitlab_url,注意跟你之後clone,pull,push的域名一致ubuntu

vim config.yml

啓動vim

./bin/install

8.(root)安裝MySQL

apt-get install -y mysql-server mysql-client libmysqlclient-dev
mysql -u root -p
建立指定mysql帳戶
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';

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

受權
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO 'gitlab'@'localhost';

9.(git)安裝gitlab主程序

cd /home/git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
git checkout 7-3-stable
cp config/gitlab.yml.example config/gitlab.yml

修改host便可,建立新用戶和新項目時提示的地址來自這裏,運行時沒有影響

vim config/gitlab.yml

sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/

mkdir /home/git/gitlab-satellites
chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
chmod -R u+rwX  public/uploads/
cp config/unicorn.rb.example config/unicorn.rb

git配置

git config --global user.name "GitLab"
git config --global user.email "gitlab@localhost"
cp config/database.yml.mysql config/database.yml

修改MySQL數據庫配置

vim config/database.yml

10.(git)安裝Gems

cd /home/git/gitlab

修改Bundle源地址爲taobao, 首行改爲 source 'http://ruby.taobao.org/'

vim Gemfile

只安裝部署模式下的mysql配置,其餘排除

bundle install --deployment --without development test postgres

11.(git)初始化數據數據庫

bundle exec rake gitlab:setup RAILS_ENV=production

12.(git)檢測一下安裝狀態

bundle exec rake gitlab:check RAILS_ENV=production

13.(root)安裝init腳本

cd /home/git/gitlab
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
update-rc.d gitlab defaults 21

14.(git)編譯靜態資源

cd /home/git/gitlab
bundle exec rake assets:precompile RAILS_ENV=production

15.(root)啓動gitlab

service gitlab start

如下添加nginx 配置 1.(root)安裝nginx

apt-get install nginx

2.(root)添加gitlab的nginx配置文件

cd /home/git/gitlab
cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

替換YOUR_SERVER_FQDN

vim /etc/nginx/sites-available/gitlab

3.(root)檢查配置文件格式並重啓測試

sudo nginx -t
sudo service nginx restart

16.(git)再次測試

cd /home/git/gitlab
bundle exec rake gitlab:check RAILS_ENV=production

完成,登陸網頁試試,初始用戶名密碼: root/5iveL!fe

相關文章
相關標籤/搜索