Centos 6.5上安装GitLab服务及问题解决(4)

#之前已经搭建过Git Server不需要再次创建Git用户
[root@Git ruby-2.1.1]# adduser --comment 'GitLab' git
[root@Git ruby-2.1.1]# passwd git
#为了方便添加git用户拥有root权限 [sudoers文件默认没有写权限需要强制保存:wq!]
[root@Git ruby-2.1.1]# vi /etc/sudoers
git    ALL=(ALL)      ALL
[root@Git ruby-2.1.1]# chmod -R 755 /home/git
[root@Git ruby-2.1.1]# vi /home/git/.bash_profile
export GIT_SSL_NO_VERIFY=1
[root@Git ruby-2.1.1]# source /home/git/.bash_profile
#不添加变量的话使用https链接会报如下错误
fatal: unable to access 'https://github.com/gitlabhq/grit.git/': Peer certificate cannot be authenticated with known CA certificates

4)安装GitLab的Shell

[root@Git git]# su - git
#克隆gitlab的shell
[git@Git ~]$ git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0
正克隆到 'gitlab-shell'...
remote: Reusing existing pack: 1222, done.
remote: Total 1222 (delta 0), reused 0 (delta 0)
接收对象中: 100% (1222/1222), 218.70 KiB | 16.00 KiB/s, done.
处理 delta 中: 100% (620/620), done.
检查连接... 完成。
[git@Git ~]$ cd gitlab-shell/
[git@Git gitlab-shell]$ cp config.yml.example config.yml
[git@Git gitlab-shell]$ vi config.yml
#自己的gitlab域名
gitlab_url: "http://git.test.com/"
#完成配置
[git@Git gitlab-shell]$ ./bin/install
mkdir -p /home/git/repositories: true
mkdir -p /home/git/.ssh: true
chmod 700 /home/git/.ssh: true
touch /home/git/.ssh/authorized_keys: true
chmod 600 /home/git/.ssh/authorized_keys: true
chmod -R ug+rwX,o-rwx /home/git/repositories: true
find /home/git/repositories -type d -print0 | xargs -0 chmod g+s: true

5)建立gitlab数据库并授权

[git@Git gitlab-shell]$ mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.36-MariaDB-wsrep MariaDB Server, wsrep_25.9.r3961
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
Query OK, 0 rows affected (0.20 sec)
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
Query OK, 1 row affected (0.11 sec)
MariaDB [(none)]> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
Query OK, 0 rows affected (0.06 sec)
MariaDB [(none)]> quit
Bye

6)克隆GitLab源

[git@Git gitlab-shell]$ cd ..
[git@Git ~]$ git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-4-stable gitlab
正克隆到 'gitlab'...
remote: Reusing existing pack: 77202, done.
remote: Counting objects: 67, done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 77269 (delta 25), reused 1 (delta 0)
接收对象中: 100% (77269/77269), 75.26 MiB | 241.00 KiB/s, done.
处理 delta 中: 100% (53687/53687), done.
[git@Git ~]$ cd gitlab
[git@Git gitlab]$ cp config/gitlab.yml.example config/gitlab.yml
[git@Git gitlab]$ vi config/gitlab.yml
## GitLab settings
gitlab:
## Web server settings
  host: git.test.com
  port: 80
  https: false
[git@Git gitlab]$ chown -R git log/
[git@Git gitlab]$ chown -R git tmp/
[git@Git gitlab]$ chmod -R u+rwX  log/
[git@Git gitlab]$ chmod -R u+rwX  tmp/
[git@Git gitlab]$ mkdir tmp/pids/
[git@Git gitlab]$ mkdir tmp/sockets/
[git@Git gitlab]$ chmod -R u+rwX  tmp/pids/
[git@Git gitlab]$ chmod -R u+rwX  tmp/sockets/
[git@Git gitlab]$ mkdir public/uploads
[git@Git gitlab]$ chmod -R u+rwX  public/uploads
[git@Git gitlab]$ cp config/unicorn.rb.example config/unicorn.rb
[git@Git gitlab]$ cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
[git@Git gitlab]$ git config --global user.name "GitLab"
[git@Git gitlab]$ git config --global user.email "gitlab@localhost"
[git@Git gitlab]$ git config --global core.autocrlf input

7)配置gitlab数据库

[git@Git gitlab]$ cp config/database.yml.mysql config/database.yml
[git@Git gitlab]$ vi config/database.yml
production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_production
  pool: 5
  username: gitlab
  password: "gitlab"
  # host: localhost
  # socket: /tmp/mysql.sock

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/e37dbe61225a187bef7dcb0655fbfcdf.html