{"id":19023,"date":"2024-11-19T17:16:49","date_gmt":"2024-11-19T09:16:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19023\/"},"modified":"2024-11-19T17:16:49","modified_gmt":"2024-11-19T09:16:49","slug":"%e6%80%8e%e4%b9%88%e5%9c%a8ubuntu%e7%b3%bb%e7%bb%9f%e4%b8%8a%e5%ae%89%e8%a3%85gitlab","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19023\/","title":{"rendered":"\u600e\u4e48\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5GitLab"},"content":{"rendered":"<p>ubuntu gitlab\u5b89\u88c5<\/p>\n<p>GitLab\u662f\u4e00\u4e2a\u57fa\u4e8eWeb\u7684Git\u4ed3\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u4f9b\u4ee3\u7801\u4ed3\u5e93\u3001\u4ee3\u7801\u5ba1\u6838\u3001\u95ee\u9898\u8ddf\u8e2a\u3001CI\/CD\u3001Wiki\u7b49\u529f\u80fd\u3002\u5b83\u662f\u4e00\u4e2a\u81ea\u6258\u7ba1\u7684Git\u4ed3\u5e93\uff0c\u53ef\u4ee5\u5728\u4e91\u5e73\u53f0\u6216\u672c\u5730\u5b89\u88c5\u6765\u7ba1\u7406\u81ea\u5df1\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5GitLab\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n<p>\u4e00\u3001\u5b89\u88c5\u4f9d\u8d56<\/p>\n<p>\u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u5305\u3002\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>sudo apt-get update<br \/>sudo apt-get install -y curl openssh-server ca-certificates postfix<\/p>\n<p>\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u8bbe\u7f6e\u90ae\u4ef6\u670d\u52a1\u5668\u7684\u914d\u7f6e\u3002\u5efa\u8bae\u9009\u62e9\u201cInternet Site\u201d\u914d\u7f6e\u3002<\/p>\n<p>\u4e8c\u3001\u5b89\u88c5GitLab<\/p>\n<p>1.\u6dfb\u52a0GitLab\u4ed3\u5e93<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u6dfb\u52a0GitLab\u4ed3\u5e93\uff1a<\/p>\n<p>curl -sS https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.deb.sh | sudo bash<\/p>\n<p>2.\u5b89\u88c5GitLab<\/p>\n<p>\u73b0\u5728\uff0c\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5GitLab\uff1a<\/p>\n<p>sudo apt-get install gitlab-ce<\/p>\n<p>\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u3002<\/p>\n<p>3.\u914d\u7f6eGitLab<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8GitLab\uff1a<\/p>\n<p>sudo gitlab-ctl reconfigure<\/p>\n<p>\u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost\u8bbf\u95eeGitLab\u3002<\/p>\n<p>\u4e09\u3001\u914d\u7f6eGitLab<\/p>\n<p>1.\u66f4\u6539\u7ba1\u7406\u5458\u5bc6\u7801<\/p>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8bbf\u95eehttp:\/\/localhost\u3002\u8f93\u5165\u521d\u59cb\u7ba1\u7406\u5458\u7528\u6237\u540droot\u548c\u5bc6\u78015iveL!fe\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\u767b\u5f55\u540e\uff0cGitLab\u5c06\u8981\u6c42\u66f4\u6539\u5bc6\u7801\u3002<\/p>\n<p>2.\u6dfb\u52a0SSH\u5bc6\u94a5<\/p>\n<p>\u8981\u5c06\u672c\u5730\u4ee3\u7801\u4e0a\u4f20\u5230GitLab\uff0c\u8bf7\u6dfb\u52a0SSH\u5bc6\u94a5\u3002<\/p>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6253\u5f00\u7ec8\u7aef\u3002\u5982\u679c\u60a8\u5df2\u7ecf\u6709SSH\u5bc6\u94a5\u5bf9\uff0c\u8bf7\u8df3\u8fc7\u6b64\u6b65\u9aa4\u3002\u5426\u5219\uff0c\u751f\u6210SSH\u5bc6\u94a5\u5bf9\uff1a<\/p>\n<p>ssh-keygen -t rsa -C &#8220;youremail@example.com&#8221;<\/p>\n<p>\u5c06\u201cyouremail@example.com\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c06SSH\u5bc6\u94a5\u6dfb\u52a0\u5230GitLab\u3002\u5728GitLab\u4e2d\uff0c\u5355\u51fb\u9875\u9762\u53f3\u4e0a\u89d2\u7684\u56fe\u6807\uff0c\u7136\u540e\u5355\u51fb\u201cSettings\u201d\u6309\u94ae\u3002<\/p>\n<p>\u5728\u201cSettings\u201d\u9875\u9762\u4e0a\uff0c\u9009\u62e9\u201cSSH Keys\u201d\u9009\u9879\u5361\u3002<\/p>\n<p>\u5c06\u516c\u94a5\u590d\u5236\u5230\u6587\u672c\u6846\u4e2d\u3002<\/p>\n<p>\u8981\u6d4b\u8bd5\u8fde\u63a5\uff0c\u53ef\u4ee5\u4ece\u7ec8\u7aef\u4e0a\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>ssh -T git@localhost<\/p>\n<p>\u56db\u3001\u521b\u5efa\u9879\u76ee<\/p>\n<p>\u73b0\u5728\uff0c\u53ef\u4ee5\u5728GitLab\u4e2d\u521b\u5efa\u65b0\u9879\u76ee\u3002<\/p>\n<p>\u5355\u51fb\u9875\u9762\u5de6\u4fa7\u83dc\u5355\u4e2d\u7684\u201cProjects\u201d\u9009\u9879\u5361\u3002\u5728\u201cProjects\u201d\u9875\u9762\u4e0a\uff0c\u5355\u51fb\u201cNew Project\u201d\u6309\u94ae\u3002<\/p>\n<p>\u8f93\u5165\u9879\u76ee\u540d\u79f0\u548c\u9879\u76ee\u63cf\u8ff0\u3002\u9009\u62e9\u5b58\u50a8\u5e93\u53ef\u89c1\u6027\u8bbe\u7f6e\u3002<\/p>\n<p>\u70b9\u51fb\u201cCreate project\u201d\u6309\u94ae\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u53ef\u4ee5\u5c06\u672c\u5730\u4ee3\u7801\u63a8\u9001\u5230GitLab\u4e2d\u3002<\/p>\n<p>\u4e94\u3001\u603b\u7ed3<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5GitLab\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002\u901a\u8fc7GitLab\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u548c\u63a7\u5236\u81ea\u5df1\u7684\u4ee3\u7801\uff0c\u5305\u62ec\u7248\u672c\u63a7\u5236\u3001\u5408\u5e76\u8bf7\u6c42\u3001CI\/CD\u7b49\u3002\u5728\u805a\u5408\u5f00\u53d1\u4e2d\uff0cGitLab\u4e5f\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u56e2\u961f\u7ba1\u7406\u4ee3\u7801\uff0c\u63d0\u9ad8\u751f\u4ea7\u6548\u7387\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5GitLab\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ubuntu gitlab\u5b89\u88c5 GitLab\u662f\u4e00\u4e2a\u57fa\u4e8eWeb\u7684Git\u4ed3\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u4f9b\u4ee3\u7801\u4ed3\u5e93\u3001\u4ee3\u7801\u5ba1\u6838\u3001\u95ee\u9898\u8ddf\u8e2a\u3001CI\/CD\u3001Wiki\u7b49\u529f\u80fd\u3002\u5b83\u662f\u4e00\u4e2a\u81ea\u6258\u7ba1\u7684Git\u4ed3\u5e93\uff0c\u53ef\u4ee5\u5728\u4e91\u5e73\u53f0\u6216\u672c\u5730\u5b89\u88c5\u6765\u7ba1\u7406\u81ea\u5df1\u7684\u4ee3\u7801\u3002 \u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5GitLab\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002 \u4e00\u3001\u5b89\u88c5\u4f9d\u8d56 \u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u5305\u3002\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo apt-get updatesudo apt-get install -y curl openssh-server ca-certificates postfix \u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u8bbe\u7f6e\u90ae\u4ef6\u670d\u52a1\u5668\u7684\u914d\u7f6e\u3002\u5efa\u8bae\u9009\u62e9\u201cInternet Site\u201d\u914d\u7f6e\u3002 \u4e8c\u3001\u5b89\u88c5GitLab 1.\u6dfb\u52a0GitLab\u4ed3\u5e93 \u5728\u547d\u4ee4\u884c\u4e2d\u6dfb\u52a0GitLab\u4ed3\u5e93\uff1a curl -sS https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.deb.sh | sudo bash 2.\u5b89\u88c5GitLab \u73b0\u5728\uff0c\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5GitLab\uff1a sudo apt-get install gitlab-ce \u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u3002 3.\u914d\u7f6eGitLab \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8GitLab\uff1a sudo gitlab-ctl reconfigure \u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost\u8bbf\u95eeGitLab\u3002 \u4e09\u3001\u914d\u7f6eGitLab 1.\u66f4\u6539\u7ba1\u7406\u5458\u5bc6\u7801 \u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8bbf\u95eehttp:\/\/localhost\u3002\u8f93\u5165\u521d\u59cb\u7ba1\u7406\u5458\u7528\u6237\u540droot\u548c\u5bc6\u78015iveL!fe\u3002 \u7b2c\u4e00\u6b21\u767b\u5f55\u540e\uff0cGitLab\u5c06\u8981\u6c42\u66f4\u6539\u5bc6\u7801\u3002 2.\u6dfb\u52a0SSH\u5bc6\u94a5 \u8981\u5c06\u672c\u5730\u4ee3\u7801\u4e0a\u4f20\u5230GitLab\uff0c\u8bf7\u6dfb\u52a0SSH\u5bc6\u94a5\u3002 \u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6253\u5f00\u7ec8\u7aef\u3002\u5982\u679c\u60a8\u5df2\u7ecf\u6709SSH\u5bc6\u94a5\u5bf9\uff0c\u8bf7\u8df3\u8fc7\u6b64\u6b65\u9aa4\u3002\u5426\u5219\uff0c\u751f\u6210SSH\u5bc6\u94a5\u5bf9\uff1a ssh-keygen -t rsa -C &#8220;youremail@example.com&#8221; \u5c06\u201cyouremail@example.com\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002 \u63a5\u4e0b\u6765\uff0c\u5c06SSH\u5bc6\u94a5\u6dfb\u52a0\u5230GitLab\u3002\u5728GitLab\u4e2d\uff0c\u5355\u51fb\u9875\u9762\u53f3\u4e0a\u89d2\u7684\u56fe\u6807\uff0c\u7136\u540e\u5355\u51fb\u201cSettings\u201d\u6309\u94ae\u3002 \u5728\u201cSettings\u201d\u9875\u9762\u4e0a\uff0c\u9009\u62e9\u201cSSH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-19023","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=19023"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19023\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}