mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-28 01:01:09 +08:00
translated
This commit is contained in:
parent
c70409b70f
commit
fed7dc53ad
@ -1,188 +0,0 @@
|
||||
[#]: subject: "How to Install GitLab on Ubuntu 22.04 | 20.04"
|
||||
[#]: via: "https://www.linuxtechi.com/how-to-install-gitlab-on-ubuntu/"
|
||||
[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How to Install GitLab on Ubuntu 22.04 | 20.04
|
||||
======
|
||||
|
||||
GitLab, an open-source platform, provides a robust and feature-rich solution for managing repositories, issues, CI/CD pipelines, and much more. If you’re an Ubuntu 22.04 or 20.04 user and want to set up your own [GitLab][1] instance to streamline your DevOps workflow, you’re in the right place.
|
||||
|
||||
This step-by-step guide will walk you through the installation process of GitLab on Ubuntu 22.04 or 20.04. GItlab comes with Enterprise edition (Gitlab EE) and Community edition (Gitlab CE). In this post , we will cover the community edition.
|
||||
|
||||
##### Prerequisites
|
||||
|
||||
- A virtual or dedicated server running Ubuntu 22.04 or 20.04 with SSH access.
|
||||
- Static Hostname ( gitlab.linuxtechi.net)
|
||||
- Sudo User with admin rights
|
||||
- 2 GB RAM or more
|
||||
- 2 vCPUs or more
|
||||
- Internet Connectivity
|
||||
|
||||
### 1) Update System Packages
|
||||
|
||||
Let’s begin by updating the package lists and upgrading any existing packages to their latest versions.
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
$ sudo apt upgrade -y
|
||||
```
|
||||
|
||||
Reboot the system after applying updates,
|
||||
|
||||
```
|
||||
$ sudo reboot.
|
||||
```
|
||||
|
||||
### 2) Install Dependencies
|
||||
|
||||
GitLab requires some dependencies to function correctly. Install them using the following commands:
|
||||
|
||||
```
|
||||
$ sudo apt install -y curl openssh-server ca-certificates postfix
|
||||
```
|
||||
|
||||
During the postfix installation, a configuration window will appear. Choose “Internet Site” and enter your server’s hostname as the mail server name. This will allow GitLab to send email notifications.
|
||||
|
||||
[,][2]
|
||||
|
||||
Choose “Internet Site” and then slect OK.
|
||||
|
||||
Check system’s hostname and choose OK.
|
||||
|
||||
### 3) Add GitLab Apt Repository
|
||||
|
||||
Now, we’ll add the GitLab repository, run the following curl command. It will automatically detect your Ubuntu version and will set the repository accordingly.
|
||||
|
||||
```
|
||||
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
|
||||
```
|
||||
|
||||
### 4) Install Gitlab
|
||||
|
||||
Run the beneath command to install and configure gitlab-ce on your ubuntu system automatically, replace the server’s hostname as your setup,
|
||||
|
||||
```
|
||||
$ sudo EXTERNAL_URL="http://gitlab.linuxtechi.net" apt install gitlab-ce
|
||||
```
|
||||
|
||||
Once the above the command is executed successfully, we will get output something like below,
|
||||
|
||||
Output above confirms that GitLab has been installed successfully. User name for gitlab web interface is root and password is stored at “/etc/gitlab/initial_root_password”
|
||||
|
||||
Note :If OS firewall is enabled on your ubuntu system, then allow 80 and 443 ports.
|
||||
|
||||
```
|
||||
$ sudo ufw allow http
|
||||
$ sudo ufw allow https
|
||||
```
|
||||
|
||||
### 5) Access GitLab Web Interface
|
||||
|
||||
With GitLab installed and configured, open your web browser and enter your server’s IP address or hostname.
|
||||
|
||||
http://<Server-IP-Address-or-Hostname>
|
||||
|
||||
- User Name: root
|
||||
- Password : <<Get Password from /etc/gitlab/initial_root_password>>
|
||||
|
||||
click on “Sign in”
|
||||
|
||||
Great, above confirms that we have successfully login to Gitlab Web interface.
|
||||
|
||||
As of now our GitLab Server is working on http (80) protocol, if you want to enable https for your GitLab, then refer the below steps,
|
||||
|
||||
### 6) Setup HTTPS for GitLab Web Interface
|
||||
|
||||
For added security, you can configure HTTPS for your GitLab instance using self-signed certificate or Let’s Encrypt. We can use Let’s encrypt only for public domain whose A recorded available on internet. But in our case, we are using a private domain, so we will be using self-signed certificate to secure GitLab.
|
||||
|
||||
Now, let’s create following folder and generate self-sign certificates using openssl command
|
||||
|
||||
```
|
||||
$ sudo mkdir -p /etc/gitlab/ssl
|
||||
$ sudo chmod 755 /etc/gitlab/ssl
|
||||
```
|
||||
|
||||
Generate the private key using following openssl command,
|
||||
|
||||
```
|
||||
$ sudo openssl genrsa -des3 -out /etc/gitlab/ssl/gitlab.linuxtechi.net.key 2048
|
||||
```
|
||||
|
||||
Enter the passphrase and and remember it
|
||||
|
||||
Create the CSR using below command,
|
||||
|
||||
```
|
||||
$ sudo openssl req -new -key /etc/gitlab/ssl/gitlab.linuxtechi.net.key -out /etc/gitlab/ssl/gitlab.linuxtechi.net.csr
|
||||
```
|
||||
|
||||
Remove Passphrase from the key, execute the following commands one after the another
|
||||
|
||||
```
|
||||
$ sudo cp -v /etc/gitlab/ssl/gitlab.linuxtechi.net.{key,original}
|
||||
$ sudo openssl rsa -in /etc/gitlab/ssl/gitlab.linuxtechi.net.original -out /etc/gitlab/ssl/gitlab.linuxtechi.net.key
|
||||
$ sudo rm -v /etc/gitlab/ssl/gitlab.linuxtechi.net.original
|
||||
```
|
||||
|
||||
Create the Certificate file
|
||||
|
||||
```
|
||||
$ sudo openssl x509 -req -days 1460 -in /etc/gitlab/ssl/gitlab.linuxtechi.net.csr -signkey /etc/gitlab/ssl/gitlab.linuxtechi.net.key -out /etc/gitlab/ssl/gitlab.linuxtechi.net.crt
|
||||
```
|
||||
|
||||
Remove the CSR file using below rm command,
|
||||
|
||||
```
|
||||
$ sudo rm -v /etc/gitlab/ssl/gitlab.linuxtechi.net.csr
|
||||
```
|
||||
|
||||
Set the permissions on key and certificate file
|
||||
|
||||
```
|
||||
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.linuxtechi.net.key
|
||||
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.linuxtechi.net.crt
|
||||
```
|
||||
|
||||
All the important configuration for Gitlab server is controlled by the file “/etc/gitlab/gitlab.rb” So edit this file, search “external_url” and add the “https://gitlab.linuxtechi.net”
|
||||
|
||||
```
|
||||
$ sudo vi /etc/gitlab/gitlab.rb
|
||||
----------------------------------------------------------
|
||||
external_url 'https://gitlab.linuxtechi.net'
|
||||
----------------------------------------------------------
|
||||
```
|
||||
|
||||
Save and exit the file, reconfigure gitlab using beneath command so that it’s web interface start working https.
|
||||
|
||||
```
|
||||
$ sudo gitlab-ctl reconfigure
|
||||
```
|
||||
|
||||
Once above command is executed successfully, then your GitLab interface should be accessible over https protocol, In my case url will be: https://gitlab.linuxtechi.net/
|
||||
|
||||
When you access it first time, it will say something like your connection is not secure, click on “Accept the Risk and Continue”
|
||||
|
||||
##### Conclusion
|
||||
|
||||
Congratulations! You’ve successfully installed GitLab on your Ubuntu 22.04 or 20.04 system. With GitLab up and running, you can now create repositories, collaborate with your team, and enhance your development workflow through GitLab’s impressive features. Enjoy seamless version control, continuous integration, and more, all under your control!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/how-to-install-gitlab-on-ubuntu/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://about.gitlab.com/
|
||||
[2]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Choose-Internet-Site-Postfix-Gitlab-Installation-Ubuntu.png
|
@ -0,0 +1,215 @@
|
||||
[#]: subject: "How to Install GitLab on Ubuntu 22.04 | 20.04"
|
||||
[#]: via: "https://www.linuxtechi.com/how-to-install-gitlab-on-ubuntu/"
|
||||
[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
如何在 Ubuntu 22.04|20.04 上安装 GitLab
|
||||
======
|
||||
|
||||
GitLab 是一个开源平台,提供了强大且功能丰富的解决方案,用于管理仓库、问题、CI/CD 管道等。如果你是 Ubuntu 22.04 或 20.04 用户,并且想要设置自己的 [GitLab][1] 实例来简化你的 DevOps 工作流程,那么你来对地方了。
|
||||
|
||||
本分步指南将引导你完成 Ubuntu 22.04 或 20.04 上 GitLab 的安装过程。GItlab 提供企业版 (Gitlab EE) 和社区版 (Gitlab CE)。在这篇文章中,我们将介绍社区版。
|
||||
|
||||
##### 先决条件
|
||||
|
||||
- 运行 Ubuntu 22.04 或 20.04 且具有 SSH 访问权限的虚拟或专用服务器。
|
||||
- 静态主机名(gitlab.linuxtechi.net)
|
||||
- 具有管理员权限的 Sudo 用户
|
||||
- 2GB 内存或更多
|
||||
- 2 个或更多 vCPU
|
||||
- 互联网连接
|
||||
|
||||
### 1) 更新系统包
|
||||
|
||||
让我们首先更新软件包列表并将任何现有软件包升级到最新版本。
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
$ sudo apt upgrade -y
|
||||
```
|
||||
|
||||
应用更新后重新启动系统。
|
||||
|
||||
```
|
||||
$ sudo reboot.
|
||||
```
|
||||
|
||||
### 2) 安装依赖项
|
||||
|
||||
GitLab 需要一些依赖项才能正常运行。使用以下命令安装它们:
|
||||
|
||||
```
|
||||
$ sudo apt install -y curl openssh-server ca-certificates postfix
|
||||
```
|
||||
|
||||
在 postfix 安装过程中,会出现一个配置窗口。选择 “Internet 站点”并输入服务器的主机名作为邮件服务器名称。这将允许 GitLab 发送电子邮件通知。
|
||||
|
||||
![][2]
|
||||
|
||||
选择 “Internet 站点”,然后选择 OK。
|
||||
|
||||
![][3]
|
||||
|
||||
检查系统的主机名并选择 OK。
|
||||
|
||||
### 3) 添加 GitLab Apt 存储库
|
||||
|
||||
现在,我们将添加 GitLab 仓库,运行以下 curl 命令。它将自动检测你的 Ubuntu 版本并相应地设置仓库。
|
||||
|
||||
```
|
||||
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
### 4) 安装 Gitlab
|
||||
|
||||
运行以下命令在你的 ubuntu 系统上自动安装和配置 gitlab-ce,将服务器的主机名替换为你的设置,
|
||||
|
||||
```
|
||||
$ sudo EXTERNAL_URL="http://gitlab.linuxtechi.net" apt install gitlab-ce
|
||||
```
|
||||
|
||||
上述命令成功执行后,我们将得到如下输出。
|
||||
|
||||
![][5]
|
||||
|
||||
![][6]
|
||||
|
||||
上面的输出确认 GitLab 已成功安装。gitlab web 界面的用户名是 root,密码存储在 “/etc/gitlab/initial_root_password”
|
||||
|
||||
注意:如果你的 ubuntu 系统上启用了操作系统防火墙,那请允许 80 和 443 端口。
|
||||
|
||||
```
|
||||
$ sudo ufw allow http
|
||||
$ sudo ufw allow https
|
||||
```
|
||||
|
||||
### 5) 访问 GitLab Web 界面
|
||||
|
||||
安装并配置 GitLab 后,打开 Web 浏览器并输入服务器的 IP 地址或主机名。
|
||||
|
||||
http://<Server-IP-Address-or-Hostname>
|
||||
|
||||
- 用户名: root
|
||||
- 密码: <<从 /etc/gitlab/initial_root_password 获取密码>>
|
||||
|
||||
![][7]
|
||||
|
||||
点击“登录”
|
||||
|
||||
![][8]
|
||||
|
||||
很好,上面确认我们已经成功登录 Gitlab Web 界面。
|
||||
|
||||
目前我们的 GitLab 服务器运行在 http(80) 协议上,如果你想为你的 GitLab 启用 https,请参考以下步骤。
|
||||
|
||||
### 6) 为 GitLab Web 界面设置 HTTPS
|
||||
|
||||
为提高安全性,可使用自签名证书或 Let's Encrypt 为 GitLab 实例配置 HTTPS。Let's Encrypt 只适用于互联网上有 A 记录的公有域。但在本例中,我们使用的是私有域,因此将使用自签名证书来确保 GitLab 的安全。
|
||||
|
||||
现在,让我们创建以下文件夹并使用 openssl 命令生成自签名证书:
|
||||
|
||||
```
|
||||
$ sudo mkdir -p /etc/gitlab/ssl
|
||||
$ sudo chmod 755 /etc/gitlab/ssl
|
||||
```
|
||||
|
||||
使用以下 openssl 命令生成私钥:
|
||||
|
||||
```
|
||||
$ sudo openssl genrsa -des3 -out /etc/gitlab/ssl/gitlab.linuxtechi.net.key 2048
|
||||
```
|
||||
|
||||
输入密码并记住它。
|
||||
|
||||
使用以下命令创建 CSR:
|
||||
|
||||
```
|
||||
$ sudo openssl req -new -key /etc/gitlab/ssl/gitlab.linuxtechi.net.key -out /etc/gitlab/ssl/gitlab.linuxtechi.net.csr
|
||||
```
|
||||
|
||||
![][9]
|
||||
|
||||
从密钥中删除 Passphrase,依次执行以下命令:
|
||||
|
||||
```
|
||||
$ sudo cp -v /etc/gitlab/ssl/gitlab.linuxtechi.net.{key,original}
|
||||
$ sudo openssl rsa -in /etc/gitlab/ssl/gitlab.linuxtechi.net.original -out /etc/gitlab/ssl/gitlab.linuxtechi.net.key
|
||||
$ sudo rm -v /etc/gitlab/ssl/gitlab.linuxtechi.net.original
|
||||
```
|
||||
|
||||
创建证书文件:
|
||||
|
||||
```
|
||||
$ sudo openssl x509 -req -days 1460 -in /etc/gitlab/ssl/gitlab.linuxtechi.net.csr -signkey /etc/gitlab/ssl/gitlab.linuxtechi.net.key -out /etc/gitlab/ssl/gitlab.linuxtechi.net.crt
|
||||
```
|
||||
|
||||
使用下面的 rm 命令删除 CSR 文件:
|
||||
|
||||
```
|
||||
$ sudo rm -v /etc/gitlab/ssl/gitlab.linuxtechi.net.csr
|
||||
```
|
||||
|
||||
设置密钥和证书文件的权限:
|
||||
|
||||
```
|
||||
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.linuxtechi.net.key
|
||||
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.linuxtechi.net.crt
|
||||
```
|
||||
|
||||
Gitlab 服务器的所有重要配置均由文件 “/etc/gitlab/gitlab.rb” 控制,因此编辑此文件,搜索 “external_url” 并添加 “https://gitlab.linuxtechi.net”
|
||||
|
||||
```
|
||||
$ sudo vi /etc/gitlab/gitlab.rb
|
||||
----------------------------------------------------------
|
||||
external_url 'https://gitlab.linuxtechi.net'
|
||||
----------------------------------------------------------
|
||||
```
|
||||
|
||||
保存并退出文件,使用下面的命令重新配置 gitlab,以便其 Web 界面可以使用 https。
|
||||
|
||||
```
|
||||
$ sudo gitlab-ctl reconfigure
|
||||
```
|
||||
|
||||
![][10]
|
||||
|
||||
成功执行上述命令后,你的 GitLab 界面应该可以通过 https 协议访问,在我的例子中,url 为:https://gitlab.linuxtechi.net/
|
||||
|
||||
当你第一次访问它时,它会说你的连接不安全,点击“接受风险并继续”
|
||||
|
||||
![][11]
|
||||
|
||||
##### 结论
|
||||
|
||||
恭喜! 你已在 Ubuntu 22.04 或 20.04 系统上成功安装 GitLab。随着 GitLab 的启动和运行,你现在可以创建仓库,与你的团队协作,并通过 GitLab 令人印象深刻的功能增强你的开发工作流程。享受无缝版本控制、持续集成等,一切尽在你的掌控之中!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/how-to-install-gitlab-on-ubuntu/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://about.gitlab.com/
|
||||
[2]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Choose-Internet-Site-Postfix-Gitlab-Installation-Ubuntu.png
|
||||
[3]: https://www.linuxtechi.com/wp-content/uploads/2018/06/System-Hostname-Postfix-Gitlab-Ubuntu.png
|
||||
[4]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Add-GitLAb-CE-Apt-Repository-Ubuntu.png
|
||||
[5]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Apt-Install-Gitlab-ce-Ubuntu.png
|
||||
[6]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Gitlab-Successful-Installlation-Message-Ubuntu.png
|
||||
[7]: https://www.linuxtechi.com/wp-content/uploads/2018/06/GitLab-Login-Page-Post-Installation-Ubuntu.png
|
||||
[8]: https://www.linuxtechi.com/wp-content/uploads/2018/06/GitLab-Web-Interface-Ubuntu.png
|
||||
[9]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Generate-CSR-Self-Sign-Cert-Gitlab.png
|
||||
[10]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Gitlab-reconfigured-Ubuntu.png
|
||||
[11]: https://www.linuxtechi.com/wp-content/uploads/2018/06/Gitlab-Web-Interface-over-Https-Ubuntu.png
|
Loading…
Reference in New Issue
Block a user