GitLab服务器搭建
GitLab服务器搭建
GitLab
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。
自建的代码托管平台,官网地址:https://about.gitlab.com/
安装说明:https://about.gitlab.com/installation/
可以看一下官网,找一下安装说明,本文以Ubuntu18.0.04为例安装搭建
1. Install and configure the necessary dependencies
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and configure an external SMTP serverafter GitLab has been installed.
sudo apt-get install -y postfix
During Postfix installation a configuration screen may appear. Select ‘Internet Site’ and press enter. Use your server’s external DNS for ‘mail name’ and press enter. If additional screens appear, continue to press enter to accept the defaults.
2. Add the GitLab package repository and install the package
Add the GitLab package repository.
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
Next, install the GitLab package. Make sure you have correctly set up your DNS, and 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.
For https://
URLs, GitLab will automatically request a certificate with Let’s Encrypt, which requires inbound HTTP access and a valid hostname. You can also use your own certificateor just use http://
(without s
).
If you would like to specify a custom password for the initial administrator user (root
), check the documentation. If a password is not specified, a random password will be automatically generated.
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee
3. Browse to the hostname and login
Unless you provided a custom password during installation, a password will be randomly generated and stored for 24 hours in /etc/gitlab/initial_root_password
. Use this password with username root
to login.
See our documentation for detailed instructions on installing and configuration).
4. Set up your communication preferences
Visit our email subscription preference centerto let us know when to communicate with you. We have an explicit email opt-in policy so you have complete control over what and how often we send you emails.
Twice a month, we send out the GitLab news you need to know, including new features, integrations, docs, and behind the scenes stories from our dev teams. For critical security updates related to bugs and system performance, sign up for our dedicated security newsletter.
Important note: If you do not opt-in to the security newsletter, you will not receive security alerts.
5. Recommended next steps
After completing your installation, consider the recommended next steps, including authentication options and sign-up restrictions.
以上就是官网给出的Ubuntu安装GitLab的方法,其实说的已经很明白,我们可以简单的操作尝试一下,大致的安装步骤在下面也会给出
安装依赖包,运行命令
sudo apt-get install curl openssh-server ca-certificates postfix1
执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)
首先信任 GitLab 的 GPG 公钥:
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
利用root用户1(不是sudo,而是root),vi打开文件/etc/apt/sources.list.d/gitlab-ce.list,加入下面一行:
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main
安装 gitlab-ce:
sudo apt-get update
sudo apt-get install gitlab-ce
上面的步骤会执行很长一段时间,看个人网速,gitlab-ce还是很大的,大约900M,安装结束后要执行一个命令
sudo gitlab-ctl reconfigure
检查GitLab是否安装好并且已经正确运行,输入下面的命令
sudo gitlab-ctl status
以上GitLab就已经安装成功,在浏览器中可以通过输入本机地址验证
localhost
或者127.0.0.1
或者本机的IP地址
如果不想每次都输入ip地址,还可以通过修改hosts文件,将自己的IP映射为域名,比如想要访问GitLab-server访问本机IP,就可以在/etc/hosts中:
127.0.0.1 GitLab-server
然后在浏览器中输入GitLab就可以访问自建的代码托管平台—GitLab
使用root用户登录,可以在里面进行新建项目、新建组、拉取小组成员、新建用户等操作
只有管理员才可以有管理权限,在左侧的菜单中可以选择新建用户等操作,在新建用户中可以选择身份是管理员还是普通用户,如果是普通用户就不能有管理权限
新建组之后可以拉取成员,拉取成员的时候会显示成员的身份,总共有5个身份,选择的时候要注意,Guest的权限最小。
在组中可以新建项目,组中的成员就可以看到该项目,然后其操作就和基本的Git操作是一样的了
Idea中集成GitLab
Idea中提供了集成GitLab的第三方插件,可以在setting—>plugins中下载GitLab Project 2020,下载完成后在setting界面的version control中就可以看到GitLab,点击添加账号,在Server URL的地方输入刚刚搭建的GitLab服务器地址,就是你的IP地址,然后协议选择HTTPS协议,就可以添加成功
在进行代码托管的时候,就和GitHub、Gitee中的操作一样了,可以选择Git clone、push、pull等操作。
补充
GitLab服务的启动、关闭和重启
启动服务
sudo gitlab-ctl start
关闭服务
sudo gitlab-ctl stop
重启服务
sudo gitlab-ctl restart
关闭服务
sudo gitlab-ctl stop
重启服务
sudo gitlab-ctl restart
还没有评论,来说两句吧...