安装要求
· Ubuntu/Debian**
· MySQL or PostgreSQL
· git
· gitlab-shell
· redis
下载的软件及版本:
安装教程
0.9. 在天朝的同学先将apt源更新成中科大或者网易的源! [重要]
1. 首先需要确定账户可以使用sudo,并更新系统package
1. apt-get update
2. apt-get upgrade
正常情况系统都带sudo命令如果没有的话手动安装下 apt-get installsudo
2. 安装一些必要包
1. sudo apt-get install -ybuild-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-devlibncurses5-dev libffi-dev curl git-core openssh-server redis-servercheckinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev vim
确定本机python版本是否为2.7 python --version
如果版本不为2.7,请安装2.7版本
1. sudo apt-get installpython2.7
2. python2--version
3. sudo ln -s/usr/bin/python /usr/bin/python2
4. sudo apt-getinstall –y python-docutils
安装邮件发送支持默认即可
1. sudo apt-get install -ypostfix
3. 安装Ruby这里我们使用taobao的镜像进行安装可以大大的缩短下载包的时间
1. mkdir /tmp/ruby&& cd /tmp/ruby
2. curl --progresshttp://ruby.taobao.org/mirrors/ruby/1.9/ruby-1.9.3-p429.tar.gz| tar xz
3. cd ruby-1.9.3-p429
4. ./configure
5. make
6. sudo makeinstall
Note: 请不要使用rvm来安装ruby可能会因为环境变量导致这样那样的错误,当然如果你能解决这些问题可以使用rvm来安装ruby
安装bundler这里我们也使用taobao镜像来缩短下载时间,注意请使用sudo!!
1. sudo gem sources--remove http://rubygems.org/
2. sudo gem sources-a http://ruby.taobao.org/
3. sudo gem installbundler --no-ri --no-rdoc
4. 添加Git用户
1. sudo adduser--disabled-login --gecos'GitLab' git
5. 安装 GitLab-shell新版本使用GitLab-shell来代替gitolite
1. # Login as git
2. sudo su git
3.
4. # Go to homedirectory
5. cd /home/git
6.
7. # Clone gitlabshell
8. git clone https://github.com/gitlabhq/gitlab-shell.git
9.
10. cd gitlab-shell
11.
12. # switch toright version
13. git checkout v1.7.0
14.
15. cpconfig.yml.example config.yml
16.
17. # Edit configand replace gitlab_url
18. # with somethinglike 'http://domain.com/'
19. #这里修改成自己的内部域名如: http://feixun.com.uloli/
20. vim config.yml
21.
22. # Do setup
23. ./bin/install
6. 安装数据库推荐MySQL
以下所有操作需要使用可以sudo的账户
1. # Install thedatabase packages
2. sudo apt-get install -ymysql-server mysql-client libmysqlclient-dev
3.
4. # Login to MySQL
5. mysql -u root -p
6.
7. # Create a userfor GitLab. (change $password to a real password)
8. mysql> CREATEUSER'gitlab'@'localhost' IDENTIFIED BY'gitlab';
9.
10. # Create theGitLab production database
11. mysql> CREATEDATABASE IF NOT EXISTS`gitlabhq_production` DEFAULTCHARACTER SET`utf8` COLLATE`utf8_unicode_ci`;
12.
13. # Grant theGitLab user necessary permissions on the table.
14. mysql> GRANTSELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON`gitlabhq_production`.* TO'gitlab'@'localhost';
7. 开始安装GitLab主程序
1. cd /home/git
2.
3. # Clone GitLabrepository
4. sudo -u git -Hgit clone https://github.com/gitlabhq/gitlabhq.git gitlab
5.
6. # Go to gitlabdir
7. cd/home/git/gitlab
8.
9. # Checkout tostable release
10. sudo -u git -Hgit checkout6-0-stable
8. 配置GitLab
1. cd/home/git/gitlab
2. # Copy theexample GitLab config
3. sudo -u git -Hcp config/gitlab.yml.example config/gitlab.yml
4.
5. # Make sure tochange "localhost" to the fully-qualified domain name of your
6. # host servingGitLab where necessary
7. #这里仅需要修改host即可,默认可行
8. sudo -u git -Hvim config/gitlab.yml
9.
10. # Make sureGitLab can write to the log/ and tmp/ directories
11. #修改账户权限
12. sudo chown -Rgit log/
13. sudo chown -Rgit tmp/
14. sudo chmod -Ru+rwX log/
15. sudo chmod -Ru+rwX tmp/
16.
17. # Createdirectory for satellites
18. sudo -u git -Hmkdir /home/git/gitlab-satellites
19.
20. # Createdirectories for sockets/pids and make sure GitLab can write to them
21. sudo -u git -H mkdirtmp/pids/
22. sudo -u git -Hmkdir tmp/sockets/
23. sudo chmod -Ru+rwX tmp/pids/
24. sudo chmod -Ru+rwX tmp/sockets/
25.
26. # Createpublic/uploads directory otherwise backup will fail
27. sudo -u git -Hmkdirpublic/uploads
28. sudo chmod -Ru+rwX public/uploads
29.
30. # Copy theexample Puma config
31. sudo -u git -Hcp config/puma.rb.example config/puma.rb
32.
33. # Copy theexample Puma config
34. #该配置文件默认即可
35. sudo -u git -Hvim config/puma.rb
36.
37. # Configure Gitglobal settings for git user, useful when editing via web
38. # Edituser.email according to what is set in gitlab.yml
39. sudo -u git -Hgit config --global user.name"GitLab"
40. sudo -u git -Hgit config --global user.email"gitlab@localhost"
41. sudo -u git -Hgit config --global core.autocrlf input
42.
1. sudo -u git cpconfig/database.yml.mysql config/database.yml
2.
3. #修改数据库账号密码,刚才添加过gitlab这个数据库用户直接修改成该账号即可
4. sudo -u git vimconfig/database.yml
5. sudo -u git -Hchmod o-rwx config/database.yml
9. 安装 Gems
1. cd/home/git/gitlab
2. sudo gem sources--remove http://rubygems.org/
3. sudo gem sources-a http://ruby.taobao.org/
4. sudo gem sources-l
5. sudo gem installcharlock_holmes --version'0.6.9.4'
6.
7. #修改Bundle源地址为taobao,首行改成 source 'http://ruby.taobao.org/'
8. sudo -u git vimGemfile
9.
10. #这个是使用mysql数据库,这个命令意思是排除postgres请别搞错
11. sudo -u git -Hbundle install --deployment --without development test postgres aws
12. #出现下面error
13. #Could not findmodernizr-2.6.2 in any of the sources
14. #解决办法修改Gemfile与Gemfile.lock
15. #gem"modernizr", "2.6.2"改为gem"modernizr-rails", "2.7.1"
16.
10. 初始化数据库并启用高级功能
1. sudo -u git -H bundleexec rake gitlab:setup RAILS_ENV=production
11. 安装init脚本
1. sudo cplib/support/init.d/gitlab /etc/init.d/gitlab
2. sudo curl--output /etc/init.d/gitlabhttps://raw.github.com/gitlabhq/gitlabhq/6-0-stable/lib/support/init.d/gitlab
3. sudo chmod +x/etc/init.d/gitlab
4.
5. #设置开机启动GitLab
6. sudo update-rc.dgitlab defaults21
7. #检查gitlab的环境配置
8. sudo -u git -Hbundle exec rake gitlab:env:info RAILS_ENV=production
9.
12. 最后检测一下程序状态
1. sudo -u git -Hbundle exec rake gitlab:setup RAILS_ENV=production
Note: 这里可能会告诉你init脚本有问题或者git版本过低,可以无视
13. 启动GitLab
1. sudo servicegitlab start
2. 或者
3. sudo/etc/init.d/gitlab restart
默认的账户如下
用户名:admin@local.host
密码: 5iveL!fe
14.仔细检查应用程序状态
1、sudo -u git -H bundle exec rake gitlab:checkRAILS_ENV=production
Nginx配置
你可以安装nginx来代理访问GitLab配置过程如下
1. 安装nginx
1. sudo apt-get install nginx
1. 增加GitLab配置文件
1. sudo curl--output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/nginx/gitlab
2.
3. sudo ln -s/etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
4. 或者取代上面两行用下面的语句
5. sudo cplib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
6.
7. #修改配置文件 Listen直接监听80端口即可 e.g. listen 80;
8. #修改server_name为你的内部域名 e.g.server_name gitlab.uloli;
9. sudo vim/etc/nginx/sites-available/gitlab
2. 重启nginx
1. sudo servicenginx restart
这样你就可以通过nginx来访问gitlab了