-
安裝 GitLab 相關套件:
# yum install curl openssh-server
# systemctl enable sshd
# systemctl start sshd
# yum install postfix
# systemctl enable postfix
# systemctl start postfix
# rpm -ivh https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
# yum install git
# yum groupinstall "Development Tools"
# yum install readline-devel zlib-devel libffi-devel libyaml-devel openssl-devel sqlite-devellibicu-devel
# curl -sSL https://rvm.io/mpapis.asc | gpg --import -
# curl -L get.rvm.io | bash -s stable
# source /etc/profile.d/rvm.sh
# rvm reload
# rvm requirements run
# rvm list known
# rvm install 2.3.3
# rvm use 2.3.3 --default
# wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
# yum install yarn
# rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
# curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
# yum install golang
# yum install nodejs
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=smtp
# firewall-cmd --permanent --add-service=ssh
# systemctl reload firewalld
-
新增 git 使用者:
#useradd -s /sbin/nologin -c "GitLab" git
-
安裝資料庫,並且設定資料庫內容:
# yum install postgresql postgresql-server postgresql-devel postgresql-contrib
(其餘細節,請參考...)
# su - postgres
$psql
postgres=# CREATE USER git CREATEDB;
postgres=# ALTER USER git WITH PASSWORD 'git';
postgres=# CREATE DATABASE gitlabhq_production OWNER git;
postgres=# \c gitlabhq_production;
gitlabhq_production=# CREATE EXTENSION IF NOT EXISTS pg_trgm;
gitlabhq_production=#\q
$ psql -U git -h 127.0.0.1 -d gitlabhq_production
gitlabhq_production=> SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'pg_trgm'
AND installed_version IS NOT NULL;
PS:如果是自行安裝的 postgreSQL 套件,請記得製作超連結:ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin
-
取得 GitLab 套件:
# mkdir /opt/git
# cd /opt/git
# git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 9-2-stable gitlab
# chown -R git /opt/git
-
編修相關設定檔:
# cd /opt/git/gitlab
# rvm install ruby-2.4.0
# rvm use ruby-2.4.0 --default
# cp config/gitlab.yml.example config/gitlab.yml
# vim config/gitlab.yml
(修改下列設定...)
host: test.example.com
email_enabled: false
(存檔離開...)
# cp config/secrets.yml.example config/secrets.yml
# chmod 0600 config/secrets.yml
# chown -R git log/
# chown -R git tmp/
# chmod -R u+rwX,go-w log/
# chmod -R u+rwX tmp/
# chmod -R u+rwX tmp/pids/
# chmod -R u+rwX tmp/sockets/
# sudo -u git -H mkdir public/uploads/
# chmod 0700 public/uploads
# chmod -R u+rwX builds/
# chmod -R u+rwX shared/artifacts/
# chmod -R ug+rwX shared/pages/
# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
# nproc
# vim config/unicorn.rb
(修改相對應的路徑,以及下列參數...)
worker_processes 4
# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
# sudo -u git -H git config --global core.autocrlf input
# sudo -u git -H git config --global gc.auto 0
# sudo -u git -H git config --global repack.writeBitmaps true
# sudo -u git -H cp config/resque.yml.example config/resque.yml
# vim config/resque.yml
(修改 redis server 相關設定,請參考...)
# chmod 777 /tmp/redis.socket
#sudo -u git cp config/database.yml.postgresql config/database.yml
#vim config/database.yml
(修改連線帳密資料...)
sudo -u git -H chmod o-rwx config/database.yml
-
整合 Ruby 的設定,並進行安裝:
# su - git
$ cd /opt/git/gitlab
$ gem uninstall bundler
$ gem install bundler:1.14.6
$ bundle install -j4 --deployment --without development test mysql aws kerberos
-
安裝與檢查 git-shell 設定:
$ bundle exec rake gitlab:shell:install REDIS_URL=unix:/tmp/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
or
$ bundle exec rake gitlab:shell:install REDIS_URL=redis://127.0.0.1:6379 AUTH=xxxxxx RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
$ vim /opt/git/gitlab-shell/config.yml
-
安裝與檢查 gitlab-workhorse 設定:
$ bundle exec rake "gitlab:workhorse:install[/opt/git/gitlab-workhorse]" RAILS_ENV=production
-
初始化資料庫設定:
$ vim /opt/git/gitlab/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb
(修改 redis 的連線 ip , db , 以及密碼!)
$ bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=git GITLAB_ROOT_EMAIL=root@localhost
(記得回答 yes)
-
保存重要的密碼設定:
$ cp config/secrets.yml /home/git/
-
部署重要的初始設定:
# cp /opt/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab
# vim /etc/init.d/gitlab
(修改路徑目錄)
# cp /opt/git/gitlab/lib/support/init.d/gitlab.default.example /etc/default/gitlab
# vim /etc/default/gitlab
(修改路徑目錄)
# chkconfig --add gitlab
# chkconfig --list gitlab
-
安裝 Gitaly:
# su - git
$ bundle exec rake "gitlab:gitaly:install[/opt/git/gitaly]" RAILS_ENV=production
$ chmod 0700 /opt/git/gitlab/tmp/sockets/private
$ chown git /opt/git/gitlab/tmp/sockets/private
$ cd /opt/git/gitaly
$ vim config.toml
-
設定轉檔功能:
$ exit
# cp /opt/git/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
# vim /etc/logrotate.d/gitlab
(修改路徑目錄)
-
確認應用程式目前的狀態:
# su - git
$ bundle exec rake gitlab:env:info RAILS_ENV=production
-
其它設定:
$ yarn install --production --pure-lockfile
$ bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
bundle exec rake gettext:compile RAILS_ENV=production
-
啟動 GitLab 服務:
# service gitlab start
-
使用 Nginx 服務:
# yum install -y nginx
# cp /opt/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf
# vim /etc/nginx/conf.d/gitlab.conf
(修改至符合的項目...)