天天看点

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

<a></a>

首先,我们需要安装 gitlab 所依赖的软件包。我们将安装 <code>curl</code>,用以下载我们所需的文件;安装<code>openssh-server</code> ,以此来通过 ssh 协议登录到我们的机器上;安装<code>ca-certificates</code>,用它来添加 ca 认证;以及<code>postfix</code>,把它作为一个 mta(mail transfer agent,邮件传输代理)。

注: 若要安装 gitlab 社区版,我们需要一个至少包含 2 gb 内存和 2 核 cpu 的 linux 机器。

鉴于这些依赖包都可以在 ubuntu 14.04 和 debian 8.x 的官方软件仓库中获取到,我们只需通过使用 <code>apt-get</code>包管理器来安装它们。为此,我们需要在一个终端或控制台中执行下面的命令:

<code># apt-get install curl openssh-server ca-certificates postfix</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

在 fedora 22 中,由于 <code>yum</code> 已经被弃用了,默认的包管理器是 <code>dnf</code>。为了安装上面那些需要的软件包,我们只需运行下面的 dnf 命令:

<code># dnf install curl openssh-server postfix</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

现在,我们将使用我们默认的初始化系统来打开 sshd 和 postfix 服务。并且我们将使得它们在每次系统启动时被自动开启。

由于在 ubuntu 14.04 中安装的是 sysvinit 初始化系统,我们将使用 service 命令来开启 sshd 和 postfix 守护进程:

<code># service sshd start</code>

<code># service postfix start</code>

现在,为了使得它们在每次开机启动时被自动开启,我们需要运行下面的 update-rc.d 命令:

<code># update-rc.d sshd enable</code>

<code># update-rc.d postfix enable</code>

鉴于 fedora 22 和 debian 8.x 已经用 systemd 代替了 sysvinit 来作为默认的初始化系统,我们只需运行下面的命令来开启 sshd 和 postfix 服务:

<code># systemctl start sshd postfix</code>

现在,为了使得它们在每次开机启动时可以自动运行,我们需要运行下面的 systemctl 命令:

<code># systemctl enable sshd postfix</code>

<code></code>

<code>created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.</code>

<code>created symlink from /etc/systemd/system/multi-user.target.wants/postfix.service to /usr/lib/systemd/system/postfix.service.</code>

现在,我们将使用 curl 从官方的 gitlab 社区版仓库下载二进制安装文件。首先,为了得到所需文件的下载链接,我们需要浏览到该软件仓库的页面。为此,我们需要在运行着相应操作系统的 linux 机器上运行下面的命令。

<code># curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.1.2-ce.0_amd64.deb</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

<code># curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/jessie/gitlab-ce_8.1.2-ce.0_amd64.deb/download</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

<code># curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm/download</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

在相应的软件源被添加到我们的 linux 机器上之后,现在我们将使用相应 linux 发行版本中的默认包管理器来安装 gitlab 社区版。

要在运行着 ubuntu 14.04 或 debian 8.x linux 发行版本的机器上安装 gitlab 社区版,我们只需运行如下的命令:

<code># dpkg -i gitlab-ce_8.1.2-ce.0_amd64.deb</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

我们只需执行下面的 dnf 命令来在我们的 fedora 22 机器上安装 gitlab。

<code># dnf install gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

gitlab 社区版已经成功地安装在我们的 linux 系统中了,接下来我们将要配置和开启它了。为此,我们需要运行下面的命令,这在 ubuntu、debian 和 fedora 发行版本上都一样:

<code># gitlab-ctl reconfigure</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

假如在我们的 linux 机器中已经启用了防火墙程序,为了使得 gitlab 社区版的 web 界面可以通过网络进行访问,我们需要允许 80 端口通过防火墙,这个端口是 gitlab 社区版的默认端口。为此,我们需要运行下面的命令。

ubuntu 14.04 默认安装和使用的是 iptables。所以,我们将运行下面的 iptables 命令来打开 80 端口:

<code># iptables -a input -p tcp -m tcp --dport 80 -j accept</code>

<code># /etc/init.d/iptables save</code>

由于 fedora 22 和 debian 8.x 默认安装了 systemd,它包含了作为防火墙程序的 firewalld。为了使得 80 端口(http 服务) 能够通过 firewalld,我们需要执行下面的命令。

<code># firewall-cmd --permanent --add-service=http</code>

<code>success</code>

<code># firewall-cmd --reload</code>

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

现在,为了登录进面板,我们需要点击登录按钮,它将询问我们的用户名和密码。然后我们将输入默认的用户名和密码,即 root 和 5ivel!fe 。在登录进控制面板后,我们将被强制要求为我们的 gitlab root 用户输入新的密码。

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

在我们成功地更改密码并登录到我们的控制面板之后,现在,我们将为我们的新项目创建一个新的仓库。为此,我们需要来到项目栏,然后点击 新项目 绿色按钮。

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

接着,我们将被询问给我们的项目输入所需的信息和设定,正如下面展示的那样。我们甚至可以从其他的 git 仓库提供商和仓库中导入我们的项目。

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

做完这些后,我们将能够使用任何包含基本 git 命令行的 git 客户端来访问我们的 git 仓库。我们可以看到在仓库中进行的任何活动,例如创建一个里程碑,管理问题,合并请求,管理成员,便签,wiki 等。

如何在 Ubuntu/Fedora/Debian 中安装 GitLab如何在 Ubuntu/Fedora/Debian 中安装 GitLab

假如你有任何的问题,建议,回馈,请将它们写在下面的评论框中,以便我们可以提升或更新我们的内容。谢谢!

本文来自云栖社区合作伙伴“linux中国”

原文发布时间为:2013-04-02.

继续阅读