1. 首页 > 软件下载 > 正文

GitLab下载-GitLab代码管理平台下载地址-GitLab代码管理平台下载方法

1. GitLab简介与版本说明

GitLab是一个开源的DevOps平台,提供代码管理、CI/CD、安全扫描等功能。它基于Git实现版本控制,支持完整的DevOps生命周期管理。更多学习教程www.fgedu.net.cn

GitLab最新版本:

GitLab 17.9(最新稳定版)- 发布于2025年,提供增强的安全性和AI功能

GitLab 17.6 – 长期支持版本,适合生产环境

GitLab 17.3 – 旧版稳定版本,维护支持中

GitLab 16.11 – 传统LTS版本

GitLab主要特性:

代码管理:Git仓库管理、代码审查、合并请求

CI/CD:内置持续集成和持续部署流水线

安全扫描:SAST、DAST、依赖扫描、容器扫描

项目管理:Issue跟踪、里程碑、看板

容器镜像仓库:内置Docker镜像仓库

2. GitLab下载方式

GitLab提供Omnibus包、Docker镜像和源码编译三种安装方式。学习交流加群风哥微信: itpux-com

方式一:下载Omnibus包(推荐)

# 添加GitLab仓库(RHEL/CentOS/Rocky 9)
# curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

# 下载GitLab CE RPM包
# cd /fgedudb/gitlab
# wget –content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/9/gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm/download.rpm

# 下载输出案例如下:
–2026-04-04 18:00:15– https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/9/gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm/download.rpm
Resolving packages.gitlab.com… 52.84.125.19
Connecting to packages.gitlab.com|52.84.125.19|:443… connected.
HTTP request sent, awaiting response… 302 Found
Location: https://gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm [following]
Length: 1234567890 (1.2G) [application/x-rpm]
Saving to: ‘gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm’

gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm 100%[===============================================>] 1.15GB 25.6MB/s in 46s

2026-04-04 18:01:01 URL:https://gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm [1234567890/1234567890] -> “gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm” [1]

# 验证下载文件
# ls -lh gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm
-rw-r–r– 1 root root 1.2G Apr 4 18:01 gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm

# 验证MD5校验和
# md5sum gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm
a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm

方式二:Docker镜像下载

# 拉取GitLab CE Docker镜像
# docker pull gitlab/gitlab-ce:latest

# 下载输出案例如下:
latest: Pulling from gitlab/gitlab-ce
Digest: sha256:a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest

# 拉取指定版本
# docker pull gitlab/gitlab-ce:17.9.0-ce.0
# docker pull gitlab/gitlab-ce:17.6.0-ce.0

# 查看镜像
# docker images gitlab/gitlab-ce
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest a1b2c3d4e5f6 2 days ago 2.8GB
gitlab/gitlab-ce 17.9.0-ce.0 a1b2c3d4e5f6 2 days ago 2.8GB
gitlab/gitlab-ce 17.6.0-ce.0 b2c3d4e5f6g7 2 weeks ago 2.7GB

# 运行GitLab容器
# docker run –detach \
–hostname gitlab.fgedu.net.cn \
–publish 443:443 –publish 80:80 –publish 22:22 \
–name gitlab \
–restart always \
–volume /srv/gitlab/config:/etc/gitlab \
–volume /srv/gitlab/logs:/var/log/gitlab \
–volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

# 查看容器状态
# docker ps | grep gitlab
a1b2c3d4e5f6 gitlab/gitlab-ce:latest “/assets/wrapper” 2 minutes ago Up 2 minutes 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp gitlab

方式三:下载企业版

# 下载GitLab EE RPM包
# wget –content-disposition https://packages.gitlab.com/gitlab/gitlab-ee/packages/el/9/gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm/download.rpm

# 下载输出案例如下:
–2026-04-04 18:05:30– https://packages.gitlab.com/gitlab/gitlab-ee/packages/el/9/gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm/download.rpm
Resolving packages.gitlab.com… 52.84.125.19
Connecting to packages.gitlab.com|52.84.125.19|:443… connected.
HTTP request sent, awaiting response… 302 Found
Length: 1456789012 (1.4G) [application/x-rpm]
Saving to: ‘gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm’

gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm 100%[===============================================>] 1.36GB 22.5MB/s in 1m2s

2026-04-04 18:06:32 URL:https://gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm [1456789012/1456789012] -> “gitlab-ee-17.9.0-ee.0.el9.x86_64.rpm” [1]

# 拉取GitLab EE Docker镜像
# docker pull gitlab/gitlab-ee:latest

3. 系统环境准备

GitLab对系统资源要求较高,需要提前规划配置。学习交流加群风哥QQ113257174

步骤1:系统要求

# 硬件要求(生产环境)
CPU: 4核心以上
内存: 8GB以上(推荐16GB)
磁盘: 100GB以上(SSD推荐)

# 端口要求
80/443: HTTP/HTTPS
22: SSH
8080: Unicorn/Puma
9090: Prometheus
5432: PostgreSQL(内置)
6379: Redis(内置)

# 安装依赖包
# yum install -y curl policycoreutils openssh-server openssh-clients
# yum install -y postfix

# 配置邮件服务
# systemctl enable postfix
# systemctl start postfix

# 配置防火墙
# firewall-cmd –permanent –add-service=http
# firewall-cmd –permanent –add-service=https
# firewall-cmd –permanent –add-port=22/tcp
# firewall-cmd –reload

# 输出案例如下:
success

步骤2:配置主机名

# 配置主机名
# hostnamectl set-hostname gitlab.fgedu.net.cn

# 配置hosts解析
# vi /etc/hosts
192.168.1.51 gitlab gitlab.fgedu.net.cn

# 验证解析
# hostname -f
gitlab.fgedu.net.cn

4. GitLab安装实战

使用Omnibus包安装GitLab是最简单的方式。更多学习教程公众号风哥教程itpux_com

步骤1:安装GitLab

# 使用yum安装(推荐)
# EXTERNAL_URL=”http://gitlab.fgedu.net.cn” yum install -y gitlab-ce

# 安装输出案例如下:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package gitlab-ce.x86_64 0:17.9.0-ce.0 will be installed
–> Finished Dependency Resolution

Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gitlab-ce x86_64 17.9.0-ce.0 gitlab_gitlab-ce 1.2 G

Transaction Summary
================================================================================
Install 1 Package

Total download size: 1.2 G
Installed size: 3.5 G
Downloading packages:
gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm | 1.2 GB 00:02:35
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gitlab-ce-17.9.0-ce.0.el9.x86_64 1/1

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure

Verifying : gitlab-ce-17.9.0-ce.0.el9.x86_64 1/1

Installed:
gitlab-ce.x86_64 0:17.9.0-ce.0

Complete!

# 或使用RPM包安装
# rpm -ivh gitlab-ce-17.9.0-ce.0.el9.x86_64.rpm

步骤2:配置GitLab

# 编辑配置文件
# vi /etc/gitlab/gitlab.rb

# 配置外部URL
external_url ‘http://gitlab.fgedu.net.cn’

# 配置时区
gitlab_rails[‘time_zone’] = ‘Asia/Shanghai’

# 配置邮件
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.fgedu.net.cn”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “gitlab@fgedu.net.cn”
gitlab_rails[‘smtp_password’] = “smtp_password”
gitlab_rails[‘smtp_domain’] = “fgedu.net.cn”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘gitlab_email_from’] = ‘gitlab@fgedu.net.cn’
gitlab_rails[‘gitlab_email_display_name’] = ‘GitLab’

# 配置SSH端口
gitlab_rails[‘gitlab_shell_ssh_port’] = 22

# 配置备份路径
gitlab_rails[‘backup_path’] = “/var/opt/gitlab/backups”
gitlab_rails[‘backup_keep_time’] = 604800

# 执行配置
# gitlab-ctl reconfigure

# 输出案例如下:
Starting Chef Infra Client, version 18.1.0
Patents: https://www.chef.io/patents
resolving cookbooks for run list: [“gitlab”]
Synchronizing Cookbooks:
– gitlab (0.0.1)
– package (0.0.1)
– runit (0.0.1)
Installing Cookbook Gems:
Compiling Cookbooks…
Recipe: gitlab::default

Chef Infra Client finished, 567/1456 resources updated in 05 minutes 30 seconds
gitlab Reconfigured!

步骤3:启动并验证

# 查看GitLab状态
# gitlab-ctl status
run: alertmanager: (pid 50123) 12345s; run: log: (pid 50124) 12345s
run: gitaly: (pid 50234) 12344s; run: log: (pid 50235) 12344s
run: gitlab-exporter: (pid 50345) 12343s; run: log: (pid 50346) 12343s
run: gitlab-kas: (pid 50456) 12342s; run: log: (pid 50457) 12342s
run: gitlab-workhorse: (pid 50567) 12341s; run: log: (pid 50568) 12341s
run: logrotate: (pid 50678) 12340s; run: log: (pid 50679) 12340s
run: nginx: (pid 50789) 12339s; run: log: (pid 50790) 12339s
run: postgres: (pid 50890) 12338s; run: log: (pid 50891) 12338s
run: prometheus: (pid 51001) 12337s; run: log: (pid 51002) 12337s
run: puma: (pid 51112) 12336s; run: log: (pid 51113) 12336s
run: redis: (pid 51223) 12335s; run: log: (pid 51224) 12335s
run: registry: (pid 51334) 12334s; run: log: (pid 51335) 12334s
run: sidekiq: (pid 51445) 12333s; run: log: (pid 51446) 12333s

# 获取初始root密码
# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails[‘initial_root_password’]` setting in `gitlab.rb`, it was provided before database was seeded in the first reconfigure run)
# 2. Until the first successful sign-in by the user
# 3. Until the user changes the password

Password: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0

# 访问Web界面
# http://gitlab.fgedu.net.cn

# 默认登录信息
# 用户名: root
# 密码: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0

# 修改root密码
# gitlab-rake “gitlab:password:reset[root]”
Enter password:
Confirm password:
Password successfully updated for user with username root.

风哥提示:GitLab首次启动需要较长时间初始化数据库和服务,请耐心等待。初始root密码存储在/etc/gitlab/initial_root_password文件中,登录后请立即修改。

5. GitLab配置实战

完成安装后,进行基础配置和安全加固。from:www.itpux.com

步骤1:配置LDAP认证

# 编辑配置文件
# vi /etc/gitlab/gitlab.rb

gitlab_rails[‘ldap_enabled’] = true
gitlab_rails[‘ldap_servers’] = YAML.load <<-'EOS' main: label: 'LDAP' host: '192.168.1.100' port: 389 uid: 'uid' bind_dn: 'cn=admin,dc=fgedu,dc=net,dc=cn' password: 'ldap_password' encryption: 'plain' verify_certificates: true active_directory: false allow_username_or_email_login: true block_auto_created_users: false base: 'ou=users,dc=fgedu,dc=net,dc=cn' user_filter: '' attributes: username: ['uid'] email: ['mail'] name: 'cn' first_name: 'givenName' last_name: 'sn' EOS # 重新配置 # gitlab-ctl reconfigure # 测试LDAP连接 # gitlab-rake gitlab:ldap:check LDAP users with access to your GitLab server (only showing the first 100 results) Checking LDAP ... LDAP: ... Server: ldap://192.168.1.100:389 LDAP authentication: Success LDAP users with access to your GitLab server: DN: uid=zhangsan,ou=users,dc=fgedu,dc=net,dc=cn User: zhangsan DN: uid=lisi,ou=users,dc=fgedu,dc=net,dc=cn User: lisi ... Done.

步骤2:配置HTTPS

# 创建SSL证书目录
# mkdir -p /etc/gitlab/ssl
# chmod 700 /etc/gitlab/ssl

# 复制证书文件
# cp /etc/pki/tls/certs/gitlab.crt /etc/gitlab/ssl/
# cp /etc/pki/tls/private/gitlab.key /etc/gitlab/ssl/
# chmod 600 /etc/gitlab/ssl/gitlab.key

# 编辑配置文件
# vi /etc/gitlab/gitlab.rb

external_url ‘https://gitlab.fgedu.net.cn’
nginx[‘redirect_http_to_https’] = true
nginx[‘ssl_certificate’] = “/etc/gitlab/ssl/gitlab.crt”
nginx[‘ssl_certificate_key’] = “/etc/gitlab/ssl/gitlab.key”
nginx[‘ssl_protocols’] = “TLSv1.2 TLSv1.3”
nginx[‘ssl_ciphers’] = “ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256”

# 重新配置
# gitlab-ctl reconfigure

# 验证HTTPS访问
# curl -k https://gitlab.fgedu.net.cn

步骤3:配置Runner

# 安装GitLab Runner
# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
# yum install -y gitlab-runner

# 注册Runner
# gitlab-runner register

# 输出案例如下:
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.fgedu.net.cn/
Enter the registration token:
GR1348941a1b2c3d4e5f6g7h8i9j0k
Enter a description for the runner:
[gitlab.fgedu.net.cn]: fgedu-runner
Enter tags for the runner (comma-separated):
docker,shell
Enter optional maintenance note for the runner:
Production runner for
WARNING: Support for registration tokens and runner parameters in the ‘register’ command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://gitlab.com/gitlab-org/gitlab/-/issues/380872
Registering runner… succeeded runner=GR1348941
Enter an executor: custom, docker, parallels, ssh, docker-ssh+machine, kubernetes, docker-windows, docker-ssh, shell, virtualbox, docker+machine, instance:
shell
Runner registered successfully. Feel free to start it, but if it’s running already the config should be automatically reloaded!

Configuration (with the authentication token) was saved to “/etc/gitlab-runner/config.toml”

# 启动Runner服务
# systemctl start gitlab-runner
# systemctl enable gitlab-runner

# 查看Runner状态
# gitlab-runner list
Runtime platform arch=amd64 os=linux pid=52001 revision=a1b2c3d4 version=17.9.0
fgedu-runner Executor=shell Token=xr-1234567890abcdef URL=https://gitlab.fgedu.net.cn/

6. GitLab使用实战

GitLab提供完整的代码管理和CI/CD功能。

步骤1:创建项目和推送代码

# 创建项目(Web界面)
# 导航到 Projects -> New project
# 选择 “Create blank project”
# Project name: fgedu-java-project
# Visibility Level: Private

# 配置Git客户端
# git config –global user.name “admin”
# git config –global user.email “admin@fgedu.net.cn”

# 克隆项目
# git clone http://gitlab.fgedu.net.cn/root/fgedu-java-project.git
Cloning into ‘fgedu-java-project’…
warning: You appear to have cloned an empty repository.

# 创建示例文件
# cd fgedu-java-project
# echo “# Java Project” > README.md
# echo “Hello World” > src/main/java/App.java
# mkdir -p src/main/java

# 提交并推送
# git add .
# git commit -m “Initial commit”
[master (root-commit) a1b2c3d] Initial commit
2 files changed, 2 insertions(+)
create mode 100644 README.md
create mode 100644 src/main/java/App.java

# git push -u origin master
Username for ‘http://gitlab.fgedu.net.cn’: root
Password for ‘http://root@gitlab.fgedu.net.cn’:
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 312 bytes | 312.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To http://gitlab.fgedu.net.cn/root/fgedu-java-project.git
* [new branch] master -> master
Branch ‘master’ set up to track remote branch ‘master’ from ‘origin’.

步骤2:配置CI/CD流水线

# 创建.gitlab-ci.yml文件
# vi .gitlab-ci.yml

stages:
– build
– test
– deploy

build_job:
stage: build
script:
– echo “Building the application…”
– mvn clean package -DskipTests
artifacts:
paths:
– target/*.jar
expire_in: 1 week

test_job:
stage: test
script:
– echo “Running tests…”
– mvn test
dependencies:
– build_job

deploy_job:
stage: deploy
script:
– echo “Deploying application…”
– echo “Deploy to production server”
environment:
name: production
url: http://app.fgedu.net.cn
only:
– master
when: manual

# 提交并推送
# git add .gitlab-ci.yml
# git commit -m “Add CI/CD pipeline”
# git push

# 查看流水线状态
# 导航到 CI/CD -> Pipelines

7. 生产环境最佳实践

在生产环境中部署GitLab需要考虑性能优化、备份恢复和高可用配置。

性能优化配置

# 配置Puma进程数
# vi /etc/gitlab/gitlab.rb

puma[‘worker_processes’] = 4
puma[‘max_threads’] = 2
puma[‘min_threads’] = 1

# 配置Sidekiq并发数
sidekiq[‘max_concurrency’] = 25

# 配置PostgreSQL
postgresql[‘shared_buffers’] = “256MB”
postgresql[‘max_connections’] = 200

# 配置Redis
redis[‘maxmemory’] = “256mb”

# 配置Gitaly
gitaly[‘configuration’] = {
concurrency: [
{
rpc: “/gitaly.SmartHTTPService/PostReceivePack”,
max_per_repo: 3
}
]
}

# 重新配置
# gitlab-ctl reconfigure

备份与恢复

# 创建备份
# gitlab-backup create

# 输出案例如下:
2026-04-04 18:30:00 +0800 — Dumping database …
2026-04-04 18:30:15 +0800 — Dumping database … done
2026-04-04 18:30:15 +0800 — Dumping repositories …
2026-04-04 18:30:45 +0800 — Dumping repositories … done
2026-04-04 18:30:45 +0800 — Dumping uploads …
2026-04-04 18:30:50 +0800 — Dumping uploads … done
2026-04-04 18:30:50 +0800 — Dumping builds …
2026-04-04 18:30:55 +0800 — Dumping builds … done
2026-04-04 18:30:55 +0800 — Dumping artifacts …
2026-04-04 18:31:00 +0800 — Dumping artifacts … done
2026-04-04 18:31:00 +0800 — Dumping pages …
2026-04-04 18:31:05 +0800 — Dumping pages … done
2026-04-04 18:31:05 +0800 — Dumping lfs objects …
2026-04-04 18:31:10 +0800 — Dumping lfs objects … done
2026-04-04 18:31:10 +0800 — Dumping container registry images …
2026-04-04 18:31:15 +0800 — Dumping container registry images … done
2026-04-04 18:31:15 +0800 — Dumping packages …
2026-04-04 18:31:20 +0800 — Dumping packages … done
2026-04-04 18:31:20 +0800 — Creating backup archive: 1712231480_2026_04_04_17.9.0_gitlab_backup.tar …
2026-04-04 18:31:45 +0800 — Creating backup archive: 1712231480_2026_04_04_17.9.0_gitlab_backup.tar … done
2026-04-04 18:31:45 +0800 — Uploading backup archive to remote storage …
2026-04-04 18:31:50 +0800 — Uploading backup archive to remote storage … done
2026-04-04 18:31:50 +0800 — Deleting old backups … done
2026-04-04 18:31:50 +0800 — Deleting tmp directories … done
2026-04-04 18:31:50 +0800 — Backup 1712231480_2026_04_04_17.9.0 is done.

# 查看备份文件
# ls -lh /var/opt/gitlab/backups/
-rw——- 1 git git 1.2G Apr 4 18:31 1712231480_2026_04_04_17.9.0_gitlab_backup.tar

# 恢复备份
# gitlab-backup restore BACKUP=1712231480_2026_04_04_17.9.0

生产环境建议:GitLab建议部署在内存至少8GB的服务器上,推荐16GB以上。建议配置独立的PostgreSQL和Redis服务。定期备份配置文件和数据。建议配置HTTPS加密传输。建议配置LDAP认证集成企业用户体系。定期更新GitLab版本获取安全补丁。

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息