目录

本地GitLab服务器搭建

本地GitLab服务器搭建

GitLab 是一个用于仓库管理系统的开源项目,使用 作为代码管理工具,并在此基础上搭建起来的Web服务。安装方法是参考GitLab在GitHub上的Wiki页面。Gitlab是被广泛使用的基于git的开源代码管理平台, 基于Ruby on Rails构建, 主要针对软件开发过程中产生的代码和文档进行管理, Gitlab主要针对group和project两个维度进行代码和文档管理, 其中group是群组, project是工程项目, 一个group可以管理多个project, 可以理解为一个群组中有多项软件开发任务, 而一个project中可能包含多个branch, 意为每个项目中有多个分支, 分支间相互独立, 不同分支可以进行归并。

通过以下命令安装GitLab依赖的工具:

sudo apt-get install -y curl openssh-server ca-certificates tzdata perl

部分版本的Ubuntu已经安装了如上工具:

https://i-blog.csdnimg.cn/blog_migrate/d6853df92509a2b7d3111a9e22971d1c.png

安装 Postfix 以发送电子邮件通知。如果您想使用其他解决方案发送电子邮件,请跳过此步骤并在安装极狐GitLab 后 。

sudo apt-get install -y postfix

sudo apt-get install -y postfix

正在读取软件包列表… 完成

正在分析软件包的依赖关系树

正在读取状态信息… 完成

下列软件包是自动安装的并且现在不需要了:

gir1.2-geocodeglib-1.0 libegl1-mesa libwayland-egl1-mesa ubuntu-web-launchers

使用’sudo apt autoremove’来卸载它(它们)。

建议安装:

procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre postfix-lmdb postfix-sqlite sasl2-bin dovecot-common resolvconf postfix-cdb postfix-doc

下列【新】软件包将被安装:

postfix

升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 10 个软件包未被升级。

需要下载 1,147 kB 的归档。

解压缩后会消耗 4,078 kB 的额外空间。

获取:1 bionic-updates/main amd64 postfix amd64 3.3.0-1ubuntu0.4 [1,147 kB]

已下载 1,147 kB,耗时 8秒 (142 kB/s)

正在预设定软件包 …

正在选中未选择的软件包 postfix。

(正在读取数据库 … 系统当前共安装有 178062 个文件和目录。)

正准备解包 …/postfix_3.3.0-1ubuntu0.4_amd64.deb  …

正在解包 postfix (3.3.0-1ubuntu0.4) …

正在设置 postfix (3.3.0-1ubuntu0.4) …

Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /lib/systemd/system/postfix.service.

正在添加组"postfix" (GID 129)…

完成。

正在添加系统用户"postfix" (UID 125)…

正在将新用户"postfix" (UID 125)添加到组"postfix"…

无法创建主目录"/var/spool/postfix"

Creating /etc/postfix/dynamicmaps.cf

正在添加组"postdrop" (GID 130)…

完成。

setting myhostname: lyb

setting alias maps

setting alias database

mailname is not a fully qualified domain name.  Not changing /etc/mailname.

setting destinations: $myhostname, lyb, localhost.localdomain, , localhost

setting relayhost:

setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

setting mailbox_size_limit: 0

setting recipient_delimiter: +

setting inet_interfaces: all

setting inet_protocols: all

/etc/aliases does not exist, creating it.

WARNING: /etc/aliases exists, but does not have a root alias.

Postfix (main.cf) is now set up with a default configuration.  If you need to

make changes, edit /etc/postfix/main.cf (and others) as needed.  To view

Postfix configuration values, see postconf(1).

After modifying main.cf, be sure to run ‘service postfix reload’.

Running newaliases

正在处理用于 ureadahead (0.100.0-21) 的触发器 …

正在处理用于 systemd (237-3ubuntu10.56) 的触发器 …

正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 …

正在处理用于 rsyslog (8.32.0-1ubuntu4.2) 的触发器 …

正在处理用于 ufw (0.36-0ubuntu0.18.04.2) 的触发器 …

正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 …

通过如下命令来配置GitLab软件镜像:

curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash

执行后会有如下信息输出:

https://i-blog.csdnimg.cn/blog_migrate/229b821539ae7268cf0f575ea99e388f.png

通过如下命令安装GitLab:

sudo apt-get install gitlab-jh

命令执行后会有如下信息输出:

https://i-blog.csdnimg.cn/blog_migrate/7e78f757e7a10ff51df00649f9811a5b.png

通过如下命令启动GitLab:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

sudo gitlab-ctl reconfigure执行时间较长,请耐心等待。执行完成之后通过如下命令来查看GitLab的状态:

sudo gitlab-ctl status

https://i-blog.csdnimg.cn/blog_migrate/d0b11afbd5cff8a0c5113e0edc958ab7.png

通过如下命令配置防火墙:

sudo ufw allow https
sudo ufw allow http
sudo ufw allow ssh
sudo ufw enable
sudo ufw status

命令执行后会有如下信息输出:

https://i-blog.csdnimg.cn/blog_migrate/05fb53fbc28666fc8a65748e68652518.png

通过如下命令设置GitLab服务自启动:

systemctl enable gitlab-runsvdir.service

访问 Linux 服务器 IP 地址即可,如果想访问 EXTERNAL_URL 指定的域名还需要配置 域名服务器或本地 hosts 文件。 初次登录时需要为 gitlab 的 root 用户设置密码。

https://i-blog.csdnimg.cn/blog_migrate/cdf07504eb67e0737057a9fbccdd27b7.png