$ sudo vim /etc/hosts
Needed to compile Ruby and native extensions to Ruby gems
$ sudo apt-get install vim # editor
$ 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 python-docutils pkg-config cmake nodejs
$ sudo apt-get install -y git git-core gitweb git-review
# Make sure Git is version 1.7.10 or higher, for example 1.7.12 or 2.0.0
$ git --version
Ruby的版本可以通过浏览http://cache.ruby-lang.org/pub/ruby/
来查到
# Remove the old Ruby 1.8 if present
$ sudo apt-get remove ruby1.8
$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl -L --progress http://cache.ruby-lang.org/pub/ruby/ruby-2.2.2.tar.gz | tar xz
$ cd ruby-2.2.2
$ ./configure --disable-install-rdoc
$ make
$ sudo make install
*修改Gem源指向taobao
https://rubygems.org/
在国内被墙着*
$ gem source -r https://rubygems.org/
$ gem source -a http://ruby.taobao.org/
$ sudo gem install bundler --no-ri --no-rdoc
接下来Gitlab安装都用这个账户
$ sudo adduser --disabled-login --gecos 'GitLab' git
用来 ssh 访问仓库的管理软件
$ 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
/etc/hosts里修改
gitlab.zjc.com
指向本机IP或者配置DNS
$ sudo vim /etc/hosts
10.1.6.49 zjc.com zjc vzjc.com mail.vzjc.com gitlab.zjc.com
$ sudo -u git -H vim /home/git/gitlab-shell/config.yml
gitlab_url: "http://gitlab.zjc.com/"
$ cd /home/git/gitlab-shell
$ sudo -u git -H ./bin/install
$ sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
下面代码中gitlabuser
, gitlabpass
为gitlabdb
分配给的用户的用户名和密码,用户可以自行设置,但是在下面用到的地方要记得修改
$ 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
# 切换到的最新稳定版号可以通过浏览器浏览`https://github.com/gitlabhq/gitlabhq`,点击branch获得
$ sudo -u git -H git checkout 7-13-stable
其中 host: 项和 gitlab-shell 中 gitlab_url 的主机一致
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.zjc.com
email_from: [email protected]
email_reply_to: [email protected]
# Make sure GitLab can write to the log/ and tmp/ directories
$ sudo chown -R git log/
$ sudo chown -R git tmp/
$ sudo chmod -R u+rwX,go-w log/
$ sudo chmod -R u+rwX tmp/
# Create directory for satellites
$ sudo -u git -H mkdir /home/git/gitlab-satellites
$ sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
$ sudo chmod -R u+rwX tmp/pids/
$ sudo chmod -R u+rwX tmp/sockets/
# Make sure GitLab can write to the public/uploads/ directory
$ sudo chmod -R u+rwX 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.zjc.com:8081", :tcp_nopush => true
$ cd /home/git/gitlab/
$ sudo -u git cp config/database.yml.mysql config/database.yml
$ sudo -u git -H vim config/database.yml
修改 Production 部分,注意这里用到的gitlabdb表的用户名和密码
production:
adapter: mysql2
encoding: utf8
collation: utf8_general_ci
reconnect: false
database: gitlabdb
pool: 10
username: gitlabuser
password: "gitlabpass"
host: localhost
socket: /var/run/mysqld/mysqld.sock
$ cd /home/git/gitlab/
$ sudo -u git -H vim config/environments/production.rb
修改 :sendmail 为 :smtp
config.action_mailer.delivery_method = :smtp
$ sudo -u git -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
$ sudo -u git -H vim config/initializers/smtp_settings.rb
地址、端口、密码等请根据实际情况配置
Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "mail.vzjc.com",
port: 587,
user_name: "[email protected]",
password: "111111",
domain: "vzjc.com",
authentication: :plain,
enable_starttls_auto: true,
openssl_verify_mode: 'none' # See ActionMailer documentation for other possible options
}
$ cd /home/git/gitlab/
$ sudo -u git -H vim Gemfile
source "http://ruby.taobao.org/"
$ cd /home/git/gitlab/
$ sudo -u git -H bundle install --deployment --without development test postgres aws kerberos
$ cd /home/git/gitlab/
$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
$ 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
ENV=production
System information
System: Ubuntu 14.04
Current User: git
Using RVM: no
Ruby Version: 2.2.3p173
Gem Version: 2.4.5.1
Bundler Version:1.10.6
Rake Version: 10.4.2
Sidekiq Version:3.3.0
GitLab information
Version: 7.14.0
Revision: 6efd0bc
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: http://gitlab.zjc.com
HTTP Clone URL: http://gitlab.zjc.com/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 2.6.4
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
$ sudo /etc/init.d/gitlab restart
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
安装方法查看本博客 Ubuntu下安装Nginx、PHP
$ 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
server {
listen 0.0.0.0:80;
listen [::]:80;
server_name gitlab.zjc.com;
[...]
location /uploads/ {
[...]
proxy_pass http://gitlab.zjc.com:8081;
}
[...]
location @gitlab {
[...]
proxy_pass http://gitlab.zjc.com:8081;
}
$ sudo /etc/init.d/nginx restart
# or
$ sudo service nginx restart
用浏览器访问: `http://gitlab.zjc.com`
用户名:root
密码:5iveL!fe
接下来做几件事儿
admin为主机上的账户,修改邮箱后会向此账户发送邮件,点击邮件里的验证,邮箱就算是彻底修改过来了
如果在配置完后又修改了Gitlab的配置文件,那么还需要执行Gitlab初始化数据库和编译操作,不然重启后无效 (测试是这样,待考证)
http://longgeek.com/2013/12/26/ci-system-structures-ii-gitlab-installation/
https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md
http://my.oschina.net/u/1158620/blog/289191