gitlab github_如何设置GitLab:一个自托管的GitHub

gitlab github

介绍 ( Introduction )

Okay -- GitLab isn't really your own self-hosted GitHub. I don't believe GitLab or GitHub share any relationship besides both being Git Management Software, but it's the best way I find to describe in laymen terms what GitLab is. GitLab is awesome. It's featured packed, and it does nearly everything that Github does. Best of all, you get unlimited private repos with it (or techincally as many as your server can handle).

好吧- GitLab是不是真的你自己托管的GitHub 。 我不相信GitLab或GitHub除了都是Git管理软件外没有任何关系,但这是我发现用外行术语描述GitLab是什么的最好方法。 GitLab很棒。 它具有打包功能,几乎可以完成Github的所有工作。 最重要的是,您将获得无限的私人存储库 (或服务器可以处理的数量最多)。

I have some pretty good DevOps skills, but I'm not really a server guy. Until recently, I've never previously wanted to deal with the hassle of setting up my own Git server, and GitHub's managed solution is really quite appealing. With GitHub, you have a reliable and easy solution that you never really have to worry about. It's also very nicely integrated with a huge array of social features like forking and organizations amongst other collaboration tools. The only thing is it can get expensive real fast if you need more than a handful of private repositories.

我有一些相当不错的DevOps技能,但是我并不是真正的服务器专家。 直到最近,我以前从未想过要设置自己的Git服务器的麻烦,而且GitHub的托管解决方案确实非常吸引人。 有了GitHub,您就拥有了一个可靠,简单的解决方案,而您从此不必担心。 它还与许多社交功能(例如分叉和组织以及其他协作工具)很好地集成在一起。 唯一的问题是,如果您需要的资源不只几个私人存储库,那么它很快就会变得昂贵。

Digital Ocean has recently made it very simple and straight forward to setup Gitlab with minimal effort and fully supporting one-click restorable backups. They also even provide great resources and tutorials on it:

最近, Digital Ocean使得设置Gitlab变得非常简单和直接,只需花费最少的精力并完全支持一键式可恢复备份。 他们甚至还提供了丰富的资源和教程:

This post will be very similar to those articles, but I'll be going through step-by-step in more detail as well as some improvements and notes of my own. Feel free to read below or go straight to the Digital Ocean docs themselves.

这篇文章与那些文章非常相似,但是我将逐步详细介绍我自己的一些改进和注释。 请随意阅读以下内容,或直接阅读Digital Ocean文档。

使用Digital Ocean注册 ( Sign up with Digital Ocean )

The first thing you'll need to do is signup with Digital Ocean.

您需要做的第一件事就是注册Digital Ocean

Screen Shot 2014-03-17 at 9.30.45 PM

设置公共SSH密钥 ( Setup Public SSH Keys )

Digital Ocean automatically will provision your server with the public keys you upload to your account. This step isn't really required, but it makes it easier and faster to access your new server environment.

Digital Ocean会自动为您的服务器提供您上传到帐户的公共密钥 。 确实不是必须执行此步骤,但是它使访问新服务器环境变得更加轻松快捷。

Screen Shot 2014-03-17 at 9.41.35 PM

创建你的液滴 ( Create Your Droplet )

If you don't know much about servers - don't worry. Digital Ocean will make this very easy for us, and they'll actually "automatically" do most of the work for us.

如果您对服务器了解不多,请放心。 Digital Ocean会让我们很容易做到这一点,他们实际上将“自动”为我们完成大部分工作。

选择您的主机名 ( Select your Hostname )

For this, use the domain (or subdomain) that you would like to use. For example, you could do gitlab.scotch.io.

为此,请使用您要使用的域(或子域)。 例如,您可以执行gitlab.scotch.io

选择服务器大小 ( Select the server size )

The official recommendation for GitLab can be found here. In summary, your server should have:

有关GitLab的官方建议可以在这里找到。 总之,您的服务器应具有:

  • 2 cores of CPU power

    2核CPU电源
  • 2 GB RAM

    2 GB内存

However, I've found that GitLab still works well even if you don't meet these requirements. If you select the smallest Droplet, GitLab will occasionally freeze or hang. This is usually fixed with a quick reboot of the server. I recommend the smallest Droplet you select is their $10/month plan. I have found no problems yet running this with a small team for both work and play.

但是,我发现即使您不满足这些要求,GitLab仍然可以正常工作。 如果选择最小的Droplet,GitLab有时会冻结或挂起。 这通常通过快速重新启动服务器来解决。 我建议您选择的最小Droplet是每月10美元的计划。 我发现与一个小团队一起工作和娱乐都没有问题。

选择一个地区 ( Select a region )

Select the region that you would like your server to be in. You should select a region that is closest to you to reduce latency.

选择您希望服务器所在的区域。您应该选择距离您最近的区域以减少延迟

选择图片 ( Select an image )

The next step is to select the GitLab application image provided by Digital Ocean. Selecting this basically means that GitLab will automatically be installed when the server is provisioned.

下一步是选择Digital Ocean提供的GitLab应用程序映像。 选择此项基本上意味着在配置服务器时将自动安装GitLab。

选择SSH密钥 ( Select the SSH Key )

Select the Public SSH Key you added from earlier. This will allow you to SSH into the server without needing a password. Selecting this also means that Digital Ocean won't send you a root password when the Droplet is created.

选择您先前添加的公共SSH密钥。 这将使您无需密码即可通过SSH进入服务器。 选择此选项还意味着在创建Droplet时,Digital Ocean不会向您发送root密码。

启用备份 ( Enable Backups )

The last step is to enable backups. Even though Git is a distributed version control system, I still would enable this so that you can easily recover your Git repos if anything unexpected happens.

最后一步是启用备份。 即使Git是分布式版本控制系统,我仍然会启用它,以便在发生任何意外情况时可以轻松恢复Git存储库。

Note: The screenshot below uses 注意:下面的屏幕快照使用 git.scotch.io as the hostname, but I ended up switching it to git.scotch.io作为主机名,但最终我将其切换为 gitlab.scotch.io. gitlab.scotch.io
long

配置服务器 ( Configure the Server )

访问液滴 ( Access the Droplet )

Now that we have created our Droplet and before we do anything, lets SSH in and make some minor setting changes. To get the IP address of your Droplet, just navigate to your Droplets in the Digital Ocean backend. After you find it, open the terminal and connect with it via SSH (no password will be required since we are using public and private keys):

现在我们已经创建了Droplet,在执行任何操作之前,请让SSH进入并进行一些小的设置更改。 要获取Droplet的IP地址,只需在Digital Ocean后端导航至Droplet。 找到它之后,打开终端并通过SSH与它连接(由于我们使用的是公钥和私钥,因此不需要密码):

ssh root@107.170.99.221
Note: You can visit the IP address in your browser now to see GitLab is working. Don't worry about that just yet, we'll get to that soon enough. 注意:您现在可以在浏览器中访问IP地址,以查看GitLab是否正在运行。 不必担心,我们会尽快解决。
Screen Shot 2014-03-17 at 10.29.18 PM

更新主机文件 ( Update the Hosts File )

This helps remove warnings when rebooting GitLab. We're going to add the hostname of your Droplet to the hosts file. To do this, open /etc/hosts with your favorite editor:

重新启动GitLab时,这有助于消除警告。 我们将把Droplet的主机名添加到hosts文件中。 为此,请使用您喜欢的编辑器打开/etc/hosts

vim /etc/hosts

Then, add your IP address, a tab, and the hostname on line 2 of that file:

然后,添加您的 IP地址,一个标签,在该文件的第2行中的主机名:

107.170.99.221 gitlab.scotch.io
Screen Shot 2014-03-18 at 12.44.12 AM

设定网址和电子邮件 ( Setup URLs and Emails )

We'll need to set some default settings and globals for GitLab. These are things like the base URL and default support email. Open the /home/git/gitlab-shell/config.yml and update the variable gitlab_url:

我们需要为GitLab设置一些默认设置和全局设置。 这些是基本URL和默认支持电子邮件之类的东西。 打开/home/git/gitlab-shell/config.yml并更新变量gitlab_url

vim /home/git/gitlab-shell/config.yml
Screen Shot 2014-03-17 at 11.32.54 PM

After that, we'll need to update one last file. Open up /home/git/gitlab/config/gitlab.yml in your editor:

之后,我们需要更新最后一个文件。 在编辑器中打开/home/git/gitlab/config/gitlab.yml

vim /home/git/gitlab/config/gitlab.yml

You can go through this file and make adjustments to customize your installation. Most of these are just default settings. For the most part you should leave it as is, but you'll need to change host under GitLab settings to your domain name.

您可以浏览此文件并进行调整以自定义安装。 其中大多数只是默认设置。 在大多数情况下,您应保持原样,但需要在GitLab设置下将host更改为您的域名。

host: gitlab.scotch.io

Then, you need to set the default From and Admin emails:

然后,您需要设置默认的发件人管理员电子邮件:

email_from: yo-its-me-gitlab@gitlab.scotch.io
support_email: nick@scotch.io
Screen Shot 2014-03-17 at 11.45.38 PM

重新启动GitLab ( Reboot GitLab )

To finalize everything, reboot GitLab with the following command:

要完成所有操作,请使用以下命令重新启动GitLab:

service gitlab restart
Screen Shot 2014-03-17 at 11.49.45 PM

设定DNS ( Setup DNS )

指向A记录 ( Point the A Record )

The final step is to now point the A record of either the domain or subdomain to your Digital Ocean IP address. I use CloudFlare to manage my domains, but your setup should look very similar to the below screenshot:

最后一步是现在将域或子域的A记录指向您的Digital Ocean IP地址。 我使用CloudFlare来管理我的域,但是您的设置应与以下屏幕截图非常相似:

Screen Shot 2014-03-18 at 12.48.04 AM

访问您的新Git服务器! ( Access Your New Git Server! )

If everything worked out correctly and DNS propagated, you can now visit the URL in your browser to access your new git server!

如果一切正常,并且DNS已传播,您现在可以在浏览器中访问URL来访问新的git服务器!

Screen Shot 2014-03-17 at 10.55.13 PM

You also can now SSH into your Droplet with the following command:

现在,您还可以使用以下命令将SSH SSH到您的Droplet:

ssh root@gitlab.scotch.io
<div class="tile">
    <div class="tile-content">
      <h2>
        Default Login
      </h2>

      <p>
        Now that you have successfully navigated to your URL, you'll need to login. The default login for this image is:
      </p>

      <pre>

admin&commat;local.host 5iveL!fe

admin&commat;local.host 5iveL!fe

<div class="alert alert-warning">
        You probably noticed this already when you were SSHing into the server. This appears in the welcome message.
      </div>

      <p>
        After you login, you'll be prompt to change the password, then you'll need to login again with the same email and the new password. Once you have logged in successfully, you'll need to change the default Admin email to your email address. To do this, navigate to the Admin Panel located here:
      </p>

      <p>
        <code>/admin/users/root/edit</code>
      </p>

      <p>
        Next, we'll need to update the default username (which is currently <strong>root</strong>). To do this, navigate to:
      </p>

      <code>/profile/account</code> After you make that change, you are all set on configuring the server!
    </div>
  </div>

  <div class="tile">
    <div class="tile-content">
      <h2>
        Next Steps
      </h2>

      <p>
        GitLab has a whole bunch of cool features. I won't go over everything in detail because a lot of it is self-explanatory, but some of the things you should consider playing around with once logged in are:
      </p>

      <ul>
        <li>
          Adding Public Keys
        </li>
        <li>
          Creating Groups and Teams
        </li>
        <li>
          Customizing Themes
        </li>
        <li>
          Your own GitLab API
        </li>
        <li>
          Webhooks
        </li>
      </ul>
    </div>
  </div>

  <div class="tile">
    <div class="tile-content">
      <h2>
        Debugging, Troubleshooting, and Backups
      </h2>

      <p>
        If GitLab ever hangs or freezes on you, you can try rebooting it with:
      </p>

      <pre>

service gitlab restart

service gitlab restart

<p>
        If that doesn't work, you can reboot your entire Droplet through the command line with:
      </p>

      <pre>

shutdown -h now

shutdown -h now

<p>
        or
      </p>

      <pre>

sudo reboot

sudo reboot

<p>
        When you do a power cycle from the command line like this, Digital Ocean will take a snapshot of your Server in case you need to safely restore. If that doesn't work, you can just login to your Digital Ocean account and reboot the Droplet through their backend.
      </p>

      <p>
        If you ever need to restore from a backup, all you have to do is log into the backend of Digital Ocean, select your Droplet, and click <i>Restore from Backup</i>.
      </p>

      <img src="https://cask.scotch.io/2014/03/Screen-Shot-2014-03-18-at-12.24.14-AM.png" alt="Screen Shot 2014-03-18 at 12.24.14 AM" class="alignnone size-full wp-image-2212 img-thumbnail" style="border: none;" />
    </div>
  </div>

  <div class="tile">
    <div class="tile-content">
      <h2>
        Conclusion
      </h2>

      <p>
        That's all there is to getting your own little private Git server. GitLab is an amazing tool, and the awesome guys over at Digital Ocean have made it really straight forward to set one up with backups, hardened security, "unlimied" privated repos, and more.
      </p>

      <p>
        I'm a huge fan of Digital Ocean and their services, and I highly recommend that you use them. GitHub is really worth every penny, but if you're in need of a ton of private repos on a tight budget, GitLab might be the best solution for you. Some other ways you could inexpensively manage your Git repos online are:
      </p>

      <ul>
        <li>
          <a href="http://bitbucket.com">BitBucket</a>
        </li>
        <li>
          <a href="https://education.github.com/">GitHub Education</a>
        </li>
      </ul>
    </div>
  </div>

翻译自: https://scotch.io/tutorials/how-to-setup-gitlab-a-self-hosted-github

gitlab github

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值