gitlab github
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文档。
The first thing you'll need to do is signup with Digital Ocean.
您需要做的第一件事就是注册Digital Ocean 。
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会自动为您的服务器提供您上传到帐户的公共密钥 。 确实不是必须执行此步骤,但是它使访问新服务器环境变得更加轻松快捷。
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会让我们很容易做到这一点,他们实际上将“自动”为我们完成大部分工作。
For this, use the domain (or subdomain) that you would like to use. For example, you could do gitlab.scotch.io
.
为此,请使用您要使用的域(或子域)。 例如,您可以执行gitlab.scotch.io
。
The official recommendation for GitLab can be found here. In summary, your server should have:
有关GitLab的官方建议可以在这里找到。 总之,您的服务器应具有:
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 the region that you would like your server to be in. You should select a region that is closest to you to reduce latency.
选择您希望服务器所在的区域。您应该选择距离您最近的区域以减少延迟 。
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。
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密码。
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存储库。
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
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
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
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
To finalize everything, reboot GitLab with the following command:
要完成所有操作,请使用以下命令重新启动GitLab:
service gitlab restart
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来管理我的域,但是您的设置应与以下屏幕截图非常相似:
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服务器!
You also can now SSH into your Droplet with the following command:
现在,您还可以使用以下命令将SSH SSH到您的Droplet:
ssh root@gitlab.scotch.io
Default Login
Now that you have successfully navigated to your URL, you'll need to login. The default login for this image is:
admin@local.host 5iveL!fe
admin@local.host 5iveL!fe
You probably noticed this already when you were SSHing into the server. This appears in the welcome message.
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:
/admin/users/root/edit
Next, we'll need to update the default username (which is currently root). To do this, navigate to:
/profile/account
After you make that change, you are all set on configuring the server!
Next Steps
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:
-
Adding Public Keys
-
Creating Groups and Teams
-
Customizing Themes
-
Your own GitLab API
-
Webhooks
Debugging, Troubleshooting, and Backups
If GitLab ever hangs or freezes on you, you can try rebooting it with:
service gitlab restart
service gitlab restart
If that doesn't work, you can reboot your entire Droplet through the command line with:
shutdown -h now
shutdown -h now
or
sudo reboot
sudo reboot
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.
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 Restore from Backup.
Conclusion
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.
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:
翻译自: https://scotch.io/tutorials/how-to-setup-gitlab-a-self-hosted-github
gitlab github