gitlab提供。deb包裏面包含gitlab社區版和它的依賴性(Ruby, PostgreSQL, Redis, Nginx, Unicorn and other gems)已經編譯。安裝此包很簡單。但因爲它將安裝本身的軟件包的依賴關係(nginx,PostgreSQL,等)node
系統使用了Ubuntu 14.04,假如的你域名爲git.example.com 而且已經安裝ruby,git servermysql
本文使用的是非root權限 須要使用sudo 進行管理
nginx
sudo apt-get update sudo apt-get upgrade
sudo adduser --disabled-login --gecos 'GitLab' git
sudo apt-get install build-essential cmake 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 git postfix
sudo apt-get install postgresql postgresql-client libpq-dev sudo -u postgres createuser --createdb git sudo -u postgres createdb --owner=git gitlabhq_production
sudo -u git -H psql -d gitlabhq_production -c "SELECT VERSION()
mkdir /home/git && cd /home/git sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-9-stable gitlab cd gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml sudo nano config/gitlab.yml
vim /home/git/gitlab/config/gitlab.yml ################################### production: &base gitlab: host: git.example.com port: 80 https: false ... email_from: gitlab@example.com ... support_email: support@example.com ###################################
sudo chown -R git {log,tmp} sudo chmod -R u+rwX {log,tmp,tmp/pids,tmp/sockets,public/uploads} sudo -u git -H mkdir /home/git/gitlab-satellites sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git cp config/database.yml.postgresql config/database.yml sudo -u git -H chmod o-rwx config/database.yml
sudo gem install bundler sudo -u git -H bundle install --deployment --without development test mysql aws sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.4] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
user: git gitlab_url: http://git.example.com/ http_settings: self_signed_cert: false repos_path: "/home/git/repositories/" auth_file: "/home/git/.ssh/authorized_keys" redis: bin: "/usr/bin/redis-cli" host: localhost port: 6379 namespace: resque:gitlab log_level: INFO audit_usernames: false
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo update-rc.d gitlab defaults 21 sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
顯示以下信息 表示系統正常
git
System information System:Ubuntu 14.04 Current User:git Using RVM:no Ruby Version:2.1.2p95 Gem Version:2.2.2 Bundler Version:1.10.6 Rake Version:10.3.1 Sidekiq Version:2.17.0 GitLab information Version:6.9.2 Revision:e46b644 Directory:/home/git/gitlab DB Adapter:postgresql URL:http://git.3nchina.cn HTTP Clone URL:http://git.3nchina.cn/some-project.git SSH Clone URL:ssh://git@git.3nchina.cn:2203/some-project.git Using LDAP:no Using Omniauth:no GitLab Shell Version:1.9.4 Repositories:/home/git/repositories/ Hooks:/home/git/gitlab-shell/hooks/ Git:/usr/bin/git
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "gitlab@example.com" sudo -u git -H git config --global core.autocrlf input
sudo service gitlab start sudo service gitlab stop sudo service gitlab restart
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab sudo vim /etc/nginx/sites-available/gitlab #eg listen 80; server_name git.example.com; server_tokens off; root /home/git/gitlab/public;
sudo rm /etc/nginx/sites-enabled/default sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab sudo service nginx restart
cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production