自己搭建git服务器:linux自己Gitlab服务
github只能保存开源项目,私有项目要收费。
公司的git不想上传个人项目,比如我的博客: https://www.zhoulujun.cn/、https://www.zhoulujun.co https://www.zhoulujun.life/
个人代码如果本地只是commit ,不上传服务器,还是不安全。
所以想在搭建自己的git服务器(想在与服务器也非常便宜
服务器快速搭建gitlab方法
centos、ununtu、Debian、AlmalLinux 官方镜像
如果是 centos、ununtu、Debian、AlmalLinux 官方镜像,直接参考官方教程安装就好,具体参看官方教程:
安装私有化部署版极狐GitLab https://about.gitlab.cn/install/#centos-7?version=ce
非官方镜像
比如tlinx,虽然是centos的内核,但是无法通过 脚本安装:
1 | curl -fsSL https: //packages .gitlab.cn /repository/raw/scripts/setup .sh | /bin/bash |
发现脚本内容:
肯定会报:!!! Unsupported OS
手动安装gitlab
选择系统对应的安装包 使用下面的命令手动安装。 比如:清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
手动下载安装
1 | wget https: //mirrors .tuna.tsinghua.edu.cn /gitlab-ce/yum/el7/gitlab-ce-10 .0.0-ce.0.el7.x86_64.rpm |
下载完成后
1 | rpm -i gitlab-ce-XXX.rpm |
启动git服务:
1 | gitlab-ctl reconfigure |
第一次访问 GitLab,系统会重定向 url 到重置密码的页面,需要输入初始化管理员账号的密码。 设置完成后,系统会重定向到登录界面,就可以使用刚才输入的密码登录系统了。
系统默认的管理员账号为 root, 登录系统后,可以修改管理员账号为自己喜欢的账号。
yum 安装
配置yum源
1 | vim /etc/yum .repos.d /gitlab-ce .repo |
添加下面内容:
1 2 3 4 5 6 | [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/e16 Repo_gpgcheck=0 Enabled=1 Gpgkey=https://packages.gitlab.com/gpg.key |
更新本地yum缓存
1 | yum makecache |
安装GitLab社区版
1 2 | yum intall gitlab-ce #自动安装最新版 yum install gitlab-ce-x.x.x #安装指定版本 |
这么其他依赖:curl policycoreutils openssh-server openssh-clients postfix 无需多说
GitLab常用命令
-
gitlab-ctl start # 启动所有 gitlab 组件;
-
gitlab-ctl stop # 停止所有 gitlab 组件;
-
gitlab-ctl restart # 重启所有 gitlab 组件;
-
gitlab-ctl status # 查看服务状态;
-
gitlab-ctl reconfigure # 启动服务;
-
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
-
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
-
gitlab-ctl tail # 查看日志;
修改GitLab配置
不修改配置,项目地址就会是 git@gitlab.example.com:zhou/zhoulujun.co.git,这个域名肯定得修改
主要修改访问IP和端口,如果有域名可以使用域名,前提域名要解析到该服务器
1 | vim /etc/gitlab/gitlab .rb |
查找external_url,改为你自己ip地址
注意:修改完成之后要在防火墙放行你的端口号
1 | firewall-cmd --permanent --add-port=10086 /tcp |
具体参看:Linux如何打开端口和设置防火墙:firewall-cmd与iptables配置 https://www.zhoulujun.cn/html/OS/Linux/LinuxDevops/7891.html
如果是腾讯云,还要去修改安全组,增加放行端口。
重启githlab
1 2 | gitlab-ctl reconfigure gitlab-ctl restart |
参考文章:
https://GitLab快速搭建 hcldirgit.github.io/2017/11/04/Git/6.GitLab快速搭建/
CentOS 搭建 GitLab https://learnku.com/articles/34145
CentOS 7搭建GitLab https://www.itze.cn/linux/761.html
在linux系统(Redhat,CentOS,Ubuntu)上搭建gitlab服务器 https://blog.51cto.com/u_15349841/3708521
转载本站文章《自己搭建git服务器:linux自己Gitlab服务》,
请注明出处:https://www.zhoulujun.cn/html/tools/VCS/git/8809.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了