现在就迫不及待的来开始我们自己的GitLab服务器的搭建吧。由于我们是个人用户的探索,所有我们选择免费的GitLab Community Edition进行演示;
1.首先,我们应该明确GitLab只支持Unix的发布版(故,我在Mac虚拟机中安装Ubuntn):
Ubuntu
Debian
CentOS……
2.其次,对硬件的要求如CPU(建议双核)、内存(建议2G)、存储、数据库和浏览器等,因为目前的电脑配置基本都满足,并且我们只是进行搭建服务器的演示操作,所以不必要过多的纠结;如果在实际的开发的场景中,请参考官方文档:https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/requirements.md;
3.安装和配置必要的依赖软件
安装过程中,提示配置General type of mail configuration选择Internet Site,提示配置System mail name输入xxx.com即可:
pengchengxiang@ubuntu:~$ sudo apt-get install curl openssh-server ca-certificates postfix
[sudo] password for pengchengxiang:
Reading package lists... Done
… …
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.
Postfix 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 '/etc/init.d/postfix reload'.
Running newaliases
Setting up ssh-import-id (5.5-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
4.添加gitlab包服务,并安装包
pengchengxiang@ubuntu:~$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
[sudo] password for pengchengxiang:
Detected operating system as Ubuntu/xenial.
… …
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
pengchengxiang@ubuntu:~$ sudo apt-get install gitlab-ce
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
… …
gitlab:
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab:
It looks like GitLab has not been configured yet; skipping the upgrade script.
5.配置和启动GitLab
第一启动的时候,会执行如安装依赖包,初始化数据库等等操作;
pengchengxiang@ubuntu:~$ sudo gitlab-ctl reconfigure
Starting Chef Client, version 12.6.0
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- package (0.0.0)
- runit (0.14.2)
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create
- change mode from '0755' to '0775'
/sbin/init: unrecognized option '--version'
-.mount loaded active mounted /
Converging 288 resources
* directory[/etc/gitlab] action nothing (skipped due to action :nothing)
... ...
- execute the ruby block reload logrotate svlogd configuration
Running handlers:
Running handlers complete
Chef Client finished, 225/313 resources updated in 02 minutes 54 seconds
gitlab Reconfigured!
6.浏览主机和登录
接下来我们在浏览器中输入localhost,就可以访问GitLab服务了,如下图:
第一次访问的时候,你将会跳转到密码重置页面来初始化管理员账户密码。输入你的密码后你将会被跳转到登录页面,默认的账户名称root。登录完成之后,你可以根据你的意愿修改用户名。
![图像](https://i-blog.csdnimg.cn/blog_migrate/937937da94301e5b87746e4a837fa7fa.png)
7.登录服务
修改密码后,登录服务如下图:
![图像](https://img-blog.csdnimg.cn/2022010615515266551.png)