GitLab 是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
本文主要用来记录安装 Gitlab 的过程,主要参考官方文档 并没有做太多的修改。
# vim /etc/apt/sources.list
deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
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 openssh-server redis-server checkinstall \libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate
sudo apt-get install -y python-docutils
sudo apt-get install -y git git-core gitweb git-review
sudo apt-get install -y git gitweb
sudo apt-get remove git-core
sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
cd /tmp
curl --progress https://git-core.googlecode.com/files/git-1.8.4.1.tar.gz | tar xz
cd git-1.8.4.1/
make prefix=/usr/local all
sudo make prefix=/usr/local install
如果升级了 git 的版本,相应修改 Gitlab.yml 中的 git 脚本位置,这一步在 clone gitlab 后在操作*
sudo -u git -H vim /home/git/gitlab/config/gitlab.yml
bin_path: /usr/local/bin/git
sudo apt-get install -y postfix
sudo apt-get remove ruby1.8
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure --disable-install-rdoc
make
sudo make install
gem source -r https://rubygems.org/
gem source -a http://ruby.taobao.org/
sudo gem install bundler --no-ri --no-rdoc
sudo adduser --disabled-login --gecos 'GitLab' git
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
sudo -u git -H cp config.yml.example config.yml
sudo -u git -H vim /home/git/gitlab-shell/config.yml
gitlab_url: "http://gitlab.thstack.com/"
url可以是自己的域名
sudo apt-get install -y mysql-server mysql-client
libmysqlclient-dev
sudo mysql -uroot -p
create database gitlabdb;
grant all on gitlabdb.* to 'gitlabuser'@'localhost' identified by 'gitlabpass';
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
sudo -u git -H git checkout 6-4-stable
cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H vim config/gitlab.yml
host: gitlab.thstack.com
email_from: [email protected]
support_mail: [email protected]
signup_enabled: true #开启用户注册
cd /home/git/gitlab
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo -u git -H mkdir public/uploads
sudo -u git -H mkdir /home/git/repositories
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo chown -R git:git log/ tmp/
sudo chmod -R u+rwX log/ tmp/ public/uploads
cd /home/git/gitlab/
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H vim config/unicorn.rb
listen "gitlab.thstack.com:8081", :tcp_nopush => true
cd /home/git/gitlab/
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo update-rc.d gitlab defaults 21
cd /home/git/gitlab/
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
cd /home/git/gitlab/
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
System information
System: Ubuntu 12.04
Current User: git
Using RVM: no
Ruby Version: 2.0.0p353
Gem Version: 2.0.14
Bundler Version:1.3.5
Rake Version: 10.1.0
GitLab information
Version: 6.4.2
Revision: 214a013
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: http://gitlab.thstack.com
HTTP Clone URL: http://gitlab.thstack.com/some-project.git
SSH Clone URL: [email protected]:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 1.8.0
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
/etc/init.d/gitlab restart
Shutting down both Unicorn and Sidekiq.
GitLab is not running.
Starting both the GitLab Unicorn and Sidekiq..
The GitLab Unicorn web server with pid 17771 is running.
The GitLab Sidekiq job dispatcher with pid 17778 is running.
GitLab and all its components are up and running
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
sudo apt-get install -y nginx
cd /home/git/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
sudo vim /etc/nginx/sites-available/gitlab
listen *:80 default_server;
server_name gitlab.thstack.com;
proxy_pass http://gitlab.thstack.com:8081;
/etc/init.d/apache2 stop
/etc/init.d/nginx restart
用浏览器访问: http://gitlab.thstack.com
用户名:[email protected]
密码:5iveL!fe