部署自己的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,如需转载请自行联系原作者

相关文章
|
9月前
|
弹性计算 人工智能 前端开发
在阿里云ECS上部署n8n自动化工作流:U2实例实战
本文介绍如何在阿里云ECS的u2i/u2a实例上部署开源工作流自动化平台n8n,利用Docker快速搭建并配置定时任务,实现如每日抓取MuleRun新AI Agent并推送通知等自动化流程。内容涵盖环境准备、安全组设置、实战案例与优化建议,助力高效构建低维护成本的自动化系统。
2093 5
|
9月前
|
Java Linux Apache
在CentOS服务器上编译并部署NiFi源码
部署Apache NiFi在CentOS上是一个涉及细节的过程,需要注意Java环境、源码编译、配置调整等多个方面。遵循上述步骤,可以在CentOS服务器上成功部署和配置Apache NiFi,从而高效地处理和分发数据。
303 17
|
10月前
|
弹性计算 安全 Linux
使用阿里云服务器安装Z-Blog博客网站流程,新手一键部署教程
本教程教你如何在阿里云99元服务器上,通过宝塔Linux面板一键部署Z-Blog博客。基于CentOS 7.9系统,从远程连接、安装宝塔面板、开放端口到部署Z-Blog全流程详解,操作简单,新手也能轻松搭建个人博客网站。
1177 13
|
10月前
|
弹性计算 Devops Shell
用阿里云 DevOps Flow 实现 ECS 部署自动化:从准备到落地的完整指南
阿里云 DevOps Flow 是一款助力开发者实现自动化部署的高效工具,支持代码流水线构建、测试与部署至ECS实例,显著提升交付效率与稳定性。本文详解如何通过 Flow 自动部署 Bash 脚本至 ECS,涵盖环境准备、流水线搭建、源码接入、部署流程设计及结果验证,助你快速上手云上自动化运维。
820 0
监控 安全 Linux
555 0
|
存储 安全 Linux
Linux服务器上安装配置GitLab的步骤。
按照以上步骤,一个基础的GitLab服务应该运行并可以使用。记得定期检查GitLab官方文档,因为GitLab的安装和配置步骤可能随着新版本而变化。
1039 0
|
Docker 容器
Docker安装Gitlab和Gitlab-Runner并实现项目CICD
Docker安装Gitlab和Gitlab-Runner并实现项目CICD
|
Shell Docker 容器
GitlabCI学习笔记之一:安装Gitlab和GitLabRunner
GitlabCI学习笔记之一:安装Gitlab和GitLabRunner