用GitLab搭建自己的私有GitHub

用GitLab搭建自己的私有GitHub

现在git是开发人员的必备技能之一,github的代码仓库管理系统目前是最好的,下面搭建私有github系统的过程。

下载gitlab:
官网地址:https://about.gitlab.com/install/
Download a GitLab Omnibus package (recommended installation)

安装gitlab:
点击对应操作系统图标可以看到详细的安装步骤教程。

 

 ===============

ubuntu
https://about.gitlab.com/install/#ubuntu

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates

sudo apt-get install -y postfix

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash


Next, install the GitLab package. Change https://gitlab.example.com to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.

sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee

==============
On CentOS 7
https://about.gitlab.com/install/#centos-7

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

安装Postfix 邮件通知功能
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

2. Add the GitLab package repository.
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ee

==============

之后就可以直接使用浏览器访问 http://ip 登录管理

个性化配置 和 注意事项

使用自己的nignx:
$ apt-get install nginx #安装nginx
$ cd /etc/nginx/conf.d && touch gitlab-http.conf

Nginx gitlab-http.conf 配置:

upstream gitlab-workhorse {
#server unix:/var/opt/gitlab/gitlab-workhorse/socket;
server 127.0.0.1:8080;
}

upstream gitlab-git-http-server {
server 127.0.0.1:8181;
}

server {
listen *:80;
server_name gitlab.guowei.com;
root /opt/gitlab/embedded/service/gitlab-rails/public;
client_max_body_size 0;
location / {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
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 http;
proxy_pass http://gitlab-workhorse;
}

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 ~ ^/[\w\.-]+/[\w\.-]+/repository/archive {
client_max_body_size 0;
error_page 418 = @git-http-server;
return 418;
}

location @git-http-server {
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;
}

}

配置gitlab不使用nginx:
$ vim /etc/gitlab/gitlab.rb
# search nginx find nginx['enable'] = true

# add
nginx['enable'] = false
gitlab_git_http_server['listen_network'] = "tcp"
gitlab_git_http_server['listen_addr'] = "127.0.0.1:8181"
# nginx['enable'] = true

$ gitlab-ctl reconfigure #配置gitlab
$ gitlab-ctl restart #重启服务


卸载gitlab:
# Stop gitlab and remove its supervision process
sudo gitlab-ctl uninstall

# Debian/Ubuntu
sudo dpkg -r gitlab-ce

# Redhat/Centos
sudo rpm -e gitlab-ce

注意事项:
为了方便以http的方式操作git仓库,在nginx中有个8181端口的配置(对应gitlab.rb中的gitlab_git_http_server配置)

下载仓库代码问题,有的可以下载,有的不可以下载
主要是国外的库问题,可以配置下本地源加快下载速度和成功率

 

posted @   大自然的流风  阅读(2632)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
历史上的今天:
2017-04-15 怎么查看CI,codeigniter的版本信息?想看某个项目中使用的CI具体是哪个版本,怎么查看?
2017-04-15 org.apache.catalina.core.StandardWrapperValve invoke的解决办法
2017-04-15 在深圳地铁卡余额不足没带现金出不去怎么办?
2017-04-15 eclipse里error报错Target runtime com.genuitec.runtime.generic.jee60 is not defined.
点击右上角即可分享
微信分享提示