部署自己的gitlab服务器

1.

yum install gcc* libicu* -y

yum install mysql-devel -y

yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker -y

yum install gettext-devel -y

yum install curl-devel -y

mkdir -p /opt/src /opt/soft

cd /opt/src

tar xf git-2.6.2.tar.xz

cd git-2.6.2

./configure --prefix=/opt/soft/git --with-curl --with-expat

make && make install

echo 'export PATH=/opt/soft/git/bin:$PATH' >> /etc/profile

source /etc/profile

git --version



git clone https://github.com/gitlabhq/gitlab-shell.git gitlab-shell

还有redis改bind ip


2.yum install mysql mysql-server mysql-devel -y


3.


tar xf ruby-2.2.3.tar.gz

cd ruby-2.2.3

./configure --prefix=/opt/soft/ruby --disable-install-rdoc

make && make install

echo 'export PATH=/opt/soft/ruby/bin:$PATH' >> /etc/profile

source /etc/profile


4.

gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/

gem install bundler --no-ri --no-rdoc


5.

tar zxf node-v4.2.2-linux-x64.tar.gz

mv node-v4.2.2-linux-x64 /opt/soft/nodejs

echo 'export PATH=/opt/soft/nodejs/bin:$PATH' >> /etc/profile


6.

tar xf go1.5.1.linux-amd64.tar 

mv go /opt/soft/

echo 'export GOROOT=/opt/soft/go' >> /etc/profile

echo 'export GOARCH=amd64' >> /etc/profile

echo 'export GOOS=linux' >> /etc/profile

echo 'export GOBIN=$GOROOT/bin' >> /etc/profile

echo 'export GOPATH=/opt/soft/go/code/go' >> /etc/profile

echo 'export PATH=$GOBIN:$PATH' >> /etc/profile



7.

create database gitlab;

grant all privileges on gitlab.* to gitlab@'localhost' identified by 'gitlab';


8.

useradd -d /opt/git git

chmod 755 /opt/git

su - git

git clone https://gitlab.com/larryli/gitlab.git -b 8-0-zh gitlab


cd gitlab/

cp config/gitlab.yml.example config/gitlab.yml

cp config/secrets.yml.example config/secrets.yml

cp config/unicorn.rb.example config/unicorn.rb

cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

cp config/resque.yml.example config/resque.yml

cp config/database.yml.mysql config/database.yml

mkdir /opt/git/gitlab-satellites/


9.修改配置文件,因为默认是在 git 账号下的 home 目录,我们这里是在 /opt/git


mkdir -p  /opt/git/gitlab-satellites /opt/git/gitlab-shell /opt/git/repositories /opt/git/gitlab-shell/hooks/


10.


redis://192.168.1.100:6379


11.bundle exec rake gitlab:shell:install[v2.6.6] REDIS_URL=redis://192.168.1.100:6379


bundle exec rake gitlab:shell:install[v2.6.6] REDIS_URL=redis://192.168.1.100:6379 RAILS_ENV=production


bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=lansgg123

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
server {
         listen       8580 ;
         server_name _;
if  ($time_iso8601 ~  "^(d{4})-(d{2})-(d{2})T(d{2}):(d{2}):(d{2})" )
{
set  $year1 $ 1 ;
set  $month1 $ 2 ;
set  $day1 $ 3 ;
set  $hour1 $ 4 ;
set  $minutes1 $ 5 ;
set  $seconds1 $ 6 ;
}
access_log   / opt / log / gitlab - $year - $month - $day.log;
error_log    / opt / log / gitlab - $year - $month - $day.error;
         root         / opt / git / gitlab / public;
   
         location  /
         {
             try_files $uri $uri / index.html $uri.html @gitlab;
         }
   
         location  / uploads /
         {
             proxy_read_timeout       300 ;
             proxy_connect_timeout    300 ;
             proxy_redirect          off;
             proxy_set_header    Host                $http_host;
             proxy_set_header    X - Real - IP           $remote_addr;
             proxy_set_header    X - Forwarded - For     $proxy_add_x_forwarded_for;
             proxy_set_header    X - Forwarded - Proto   $scheme;
             proxy_set_header    X - Frame - Options     SAMEORIGIN;
             proxy_pass http: / / gitlab;
         }
   
         location @gitlab
         {
             proxy_read_timeout       300 ;
             proxy_connect_timeout    300 ;
             proxy_redirect          off;
             proxy_set_header    Host                $http_host;
             proxy_set_header    X - Real - IP           $remote_addr;
             proxy_set_header    X - Forwarded - For     $proxy_add_x_forwarded_for;
             proxy_set_header    X - Forwarded - Proto   $scheme;
             proxy_set_header    X - Frame - Options     SAMEORIGIN;
             proxy_pass http: / / gitlab;
         }
   
         location ~ [ - \ / \w\.] + \.git\ /
         {
             proxy_read_timeout       300 ;
             proxy_connect_timeout    300 ;
             proxy_redirect          off;
             proxy_buffering off;
             proxy_set_header    Host                $http_host;
             proxy_set_header    X - Real - IP           $remote_addr;
             proxy_set_header    X - Forwarded - For     $proxy_add_x_forwarded_for;
             proxy_set_header    X - Forwarded - Proto   $scheme;
             proxy_pass http: / / gitlab - git - http - server;
         }
   
         location ~ ^ / (assets) /
         {
             root  / opt / git / gitlab / public;
             #gzip_static on;
             expires  max ;
             add_header Cache - Control public;
         }
   
         error_page  502  / 502.html ;
     }
1
gitlab新建文件报错Commit was rejected by pre - receive hook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/ home / git / gitlab / config / gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host:  172.18 . 84.17
  port:  80  # Set to 443 if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
https: false  # Set to true if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
[root@solr2 git] # cat /home/git/gitlab-shell/config.yml
- - -
user: git
gitlab_url: http: / / 172.18 . 84.17 /
http_settings:
self_signed_cert: true
repos_path:  "/home/git/repositories/"
auth_file:  "/home/git/.ssh/authorized_keys"
redis:
bin "/usr/bin/redis-cli"
namespace: resque:gitlab
socket:  "/var/run/redis/redis.sock"
log_level: INFO
audit_usernames: false

or https

1
2
3
4
5
6
7
8
9
10
11
12
user: git
gitlab_url: https: / / 172.18 . 84.17 /
http_settings:
self_signed_cert: true
repos_path:  "/home/git/repositories/"
auth_file:  "/home/git/.ssh/authorized_keys"
redis:
bin "/usr/bin/redis-cli"
namespace: resque:gitlab
socket:  "/var/run/redis/redis.sock"
log_level: INFO
audit_usernames: false


cat /etc/profile

export JAVA_HOME=/usr/java/jdk

export JRE_HOME=/usr/java/jdk/jre

exportCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

export PATH=/root/shell:$JAVA_HOME/bin:$PATH


export ANDROID_SDK_HOME=/usr/java/android-sdk-linux

export GRADLE_HOME=/usr/java/gradle-3.3


export MAVEN_HOME=/usr/java/apache-maven-3.3.9

export PATH=/usr/local/apr/bin:$MAVEN_HOME/bin:$PATH

export PATH=$ANDROID_SDK_HOME/tools:$ANDROID_SDK_HOME/platform-tools:$GRADLE_HOME/bin:/usr/local/apr/bin:/usr/java/apache-maven-3.3.9/bin:/root/shell:/usr/java/jdk/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin

export MAVEN_OPTS="-Xms1024m -Xmx1024m"



本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1956912,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值