{"id":18811,"date":"2024-11-19T08:57:19","date_gmt":"2024-11-19T00:57:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18811\/"},"modified":"2024-11-19T08:57:19","modified_gmt":"2024-11-19T00:57:19","slug":"%e6%b5%85%e6%9e%90gitlab%e7%9a%84%e5%ae%89%e8%a3%85%e6%ad%a5%e9%aa%a4%e5%8f%8a%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18811\/","title":{"rendered":"\u6d45\u6790GitLab\u7684\u5b89\u88c5\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879"},"content":{"rendered":"<p>gitlab\u662f\u4e00\u4e2a\u57fa\u4e8eweb\u7684git\u5b58\u50a8\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u7ba1\u7406\u56e2\u961f\u7684\u4ee3\u7801\u3001\u6587\u6863\u548c\u8fdb\u5ea6\u3002\u5b89\u88c5gitlab\u53ef\u4ee5\u4f7f\u56e2\u961f\u6210\u5458\u53ef\u4ee5\u5728\u540c\u4e00\u5e73\u53f0\u4e0a\u534f\u4f5c\u5f00\u53d1\u548c\u7ba1\u7406\u4ee3\u7801\uff0c\u4ece\u800c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u56e2\u961f\u6c9f\u901a\u6548\u679c\u3002\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecdgitlab\u7684\u5b89\u88c5\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<p>\u4e00\u3001\u5b89\u88c5\u524d\u7684\u51c6\u5907\u5de5\u4f5c<br \/>\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u505a\u597d\u4e86\u4ee5\u4e0b\u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n<p>1.\u9009\u62e9\u5408\u9002\u7684\u670d\u52a1\u5668\uff1a\u8981\u5b89\u88c5GitLab\uff0c\u60a8\u9700\u8981\u4e00\u53f0\u7269\u7406\u670d\u52a1\u5668\u6216\u865a\u62df\u673a\uff0c\u4ee5\u8fd0\u884cGitLab\u7684\u8f6f\u4ef6\u5305\u548c\u76f8\u5173\u670d\u52a1\u3002\u5efa\u8bae\u9009\u62e9\u4e00\u53f0\u6027\u80fd\u8f83\u597d\u3001\u5185\u5b58\u5927\u4e8e\u6216\u7b49\u4e8e2GB\u7684\u670d\u52a1\u5668\uff0c\u4ee5\u4fdd\u8bc1\u4f7f\u7528GitLab\u65f6\u7684\u7a33\u5b9a\u548c\u6d41\u7545\u3002<\/p>\n<p>2.\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\uff1a\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5GitLab\u9700\u8981\u4e00\u4e9b\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305\uff0c\u5982\uff1acurl\u3001openssh-server\u3001ca-certificates\u7b49\uff0c\u8bf7\u5728\u5b89\u88c5GitLab\u4e4b\u524d\u5148\u5b89\u88c5\u8fd9\u4e9b\u8f6f\u4ef6\u5305\u3002<\/p>\n<p>3.\u51c6\u5907\u6570\u636e\u5e93\uff1aGitLab\u9700\u8981\u4e00\u4e2a\u6570\u636e\u5e93\u6765\u5b58\u50a8\u6240\u6709\u4fe1\u606f\u3002\u60a8\u53ef\u4ee5\u9009\u62e9\u5b89\u88c5MySQL\u6216PostgreSQL\uff0c\u4f46\u5efa\u8bae\u5b89\u88c5PostgreSQL\u3002\u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u5148\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3001\u7528\u6237\u548c\u5bc6\u7801\uff0c\u4ee5\u4f9bGitLab\u4f7f\u7528\u3002<\/p>\n<p>\u4e8c\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab<br \/>1.\u4e0b\u8f7dGitLab\uff1a\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u5148\u4eceGitLab\u5b98\u65b9\u7f51\u7ad9\uff08https:\/\/about.gitlab.com\/install\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684GitLab\u8f6f\u4ef6\u5305\u3002<\/p>\n<p>2.\u5b89\u88c5GitLab\uff1a\u5f53\u4e0b\u8f7dGitLab\u8f6f\u4ef6\u5305\u540e\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<p>\uff081\uff09\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\u4e4b\u524d\uff0c\u8bf7\u5148\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a<br \/> &nbsp; sudo apt-get update<br \/> &nbsp; sudo apt-get install -y curl openssh-server ca-certificates<\/p>\n<p>\uff082\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\uff1a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\uff1a<br \/> &nbsp; cd \/tmp<br \/> &nbsp; curl -LO https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ee\/script.deb.sh<br \/> &nbsp; sudo bash \/tmp\/script.deb.sh<br \/> &nbsp; sudo EXTERNAL_URL=&#8221;http:\/\/gitlab.example.com&#8221; apt-get install gitlab-ee<\/p>\n<p>\u6ce8\uff1a\u5c06http:\/\/gitlab.example.com\u66ff\u6362\u4e3a\u60a8\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\u3002<\/p>\n<p>\uff083\uff09\u6253\u5f00\u9632\u706b\u5899\u7aef\u53e3\uff1a\u8981\u8bbf\u95eeGitLab Web\u754c\u9762\uff0c\u60a8\u9700\u8981\u6253\u5f00GitLab\u6240\u9700\u7684\u7aef\u53e3\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGitLab\u9700\u8981\u6253\u5f00HTTP\uff0880\u7aef\u53e3\uff09\u548cHTTPS\uff08443\u7aef\u53e3\uff09\u7aef\u53e3\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u7aef\u53e3\uff1a<\/p>\n<p>sudo ufw allow http<br \/>sudo ufw allow https<\/p>\n<p>\uff084\uff09\u91cd\u542fGitLab\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u542fGitLab\uff1a<br \/> &nbsp; sudo gitlab-ctl reconfigure<\/p>\n<p>\u4e09\u3001\u914d\u7f6eGitLab<br \/>\u5728\u5b89\u88c5GitLab\u540e\uff0c\u60a8\u9700\u8981\u8fdb\u884c\u4e9b\u7b80\u5355\u7684\u8bbe\u7f6e\u6765\u914d\u7f6eGitLab\u3002\u4ee5\u4e0b\u662f\u5b8c\u6210\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u7684\u6b65\u9aa4\u3002<\/p>\n<p>1.\u914d\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\uff1aGitLab\u9700\u8981SMTP\u90ae\u4ef6\u670d\u52a1\u6765\u53d1\u9001\u90ae\u4ef6\u7ed9\u7528\u6237\u3002\u60a8\u9700\u8981\u8bbe\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\u624d\u80fd\u5411\u7528\u6237\u53d1\u9001\u90ae\u4ef6\u3002\u53ef\u4ee5\u6309\u7167GitLab\u6587\u6863\uff08https:\/\/docs.gitlab.com\/omnibus\/settings\/smtp.html\uff09\u914d\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\u3002<\/p>\n<p>2.\u4fee\u6539Root\u5bc6\u7801\uff1a\u5728\u5b89\u88c5GitLab\u540e\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u7528\u6237\u540d\u201croot\u201d\u548c\u521d\u59cb\u5bc6\u7801\u201c5iveL!fe\u201d\uff0c\u4f46\u5efa\u8bae\u60a8\u7acb\u5373\u66f4\u6539\u5bc6\u7801\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u6539Root\u5bc6\u7801\uff1a<\/p>\n<p>sudo gitlab-rails console<br \/>user = User.where(id: 1).first<br \/>user.password = &#8216;new_password&#8217;<br \/>user.password_confirmation = &#8216;new_password&#8217;<br \/>user.save!<\/p>\n<p>3.\u521b\u5efa\u7528\u6237\uff1aGitLab\u652f\u6301\u591a\u4e2a\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u8bb8\u591a\u7528\u6237\u4ee5\u52a0\u5165\u548c\u7ba1\u7406\u4ee3\u7801\u3002\u53ef\u4ee5\u6309\u7167GitLab\u6587\u6863\uff08https:\/\/docs.gitlab.com\/ee\/user\/project\/members\/index.html\uff09\u521b\u5efa\u548c\u6dfb\u52a0\u7528\u6237\u3002<\/p>\n<p>\u56db\u3001\u603b\u7ed3<br \/>\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u5b89\u88c5GitLab\u4ee5\u53ca\u5728\u5b89\u88c5\u540e\u5982\u4f55\u8fdb\u884cGitLab\u7684\u914d\u7f6e\u3002\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u505a\u597d\u4e86\u51c6\u5907\u5de5\u4f5c\uff0c\u5982\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u3001\u521b\u5efa\u6570\u636e\u5e93\u3001\u51c6\u5907SMTP\u90ae\u4ef6\u670d\u52a1\u7b49\u3002\u901a\u8fc7\u672c\u6587\u63d0\u4f9b\u7684\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u6210\u529f\u5b89\u88c5\u548c\u914d\u7f6e\u6700\u65b0\u7248\u672c\u7684GitLab\uff0c\u5e76\u4e0e\u60a8\u7684\u56e2\u961f\u4e00\u8d77\u534f\u4f5c\u5f00\u53d1\u548c\u7ba1\u7406\u4ee3\u7801\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6d45\u6790GitLab\u7684\u5b89\u88c5\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\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>gitlab\u662f\u4e00\u4e2a\u57fa\u4e8eweb\u7684git\u5b58\u50a8\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u7ba1\u7406\u56e2\u961f\u7684\u4ee3\u7801\u3001\u6587\u6863\u548c\u8fdb\u5ea6\u3002\u5b89\u88c5gitlab\u53ef\u4ee5\u4f7f\u56e2\u961f\u6210\u5458\u53ef\u4ee5\u5728\u540c\u4e00\u5e73\u53f0\u4e0a\u534f\u4f5c\u5f00\u53d1\u548c\u7ba1\u7406\u4ee3\u7801\uff0c\u4ece\u800c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u56e2\u961f\u6c9f\u901a\u6548\u679c\u3002\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecdgitlab\u7684\u5b89\u88c5\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\u3002 \u4e00\u3001\u5b89\u88c5\u524d\u7684\u51c6\u5907\u5de5\u4f5c\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u505a\u597d\u4e86\u4ee5\u4e0b\u51c6\u5907\u5de5\u4f5c\uff1a 1.\u9009\u62e9\u5408\u9002\u7684\u670d\u52a1\u5668\uff1a\u8981\u5b89\u88c5GitLab\uff0c\u60a8\u9700\u8981\u4e00\u53f0\u7269\u7406\u670d\u52a1\u5668\u6216\u865a\u62df\u673a\uff0c\u4ee5\u8fd0\u884cGitLab\u7684\u8f6f\u4ef6\u5305\u548c\u76f8\u5173\u670d\u52a1\u3002\u5efa\u8bae\u9009\u62e9\u4e00\u53f0\u6027\u80fd\u8f83\u597d\u3001\u5185\u5b58\u5927\u4e8e\u6216\u7b49\u4e8e2GB\u7684\u670d\u52a1\u5668\uff0c\u4ee5\u4fdd\u8bc1\u4f7f\u7528GitLab\u65f6\u7684\u7a33\u5b9a\u548c\u6d41\u7545\u3002 2.\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\uff1a\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5GitLab\u9700\u8981\u4e00\u4e9b\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305\uff0c\u5982\uff1acurl\u3001openssh-server\u3001ca-certificates\u7b49\uff0c\u8bf7\u5728\u5b89\u88c5GitLab\u4e4b\u524d\u5148\u5b89\u88c5\u8fd9\u4e9b\u8f6f\u4ef6\u5305\u3002 3.\u51c6\u5907\u6570\u636e\u5e93\uff1aGitLab\u9700\u8981\u4e00\u4e2a\u6570\u636e\u5e93\u6765\u5b58\u50a8\u6240\u6709\u4fe1\u606f\u3002\u60a8\u53ef\u4ee5\u9009\u62e9\u5b89\u88c5MySQL\u6216PostgreSQL\uff0c\u4f46\u5efa\u8bae\u5b89\u88c5PostgreSQL\u3002\u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u5148\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3001\u7528\u6237\u548c\u5bc6\u7801\uff0c\u4ee5\u4f9bGitLab\u4f7f\u7528\u3002 \u4e8c\u3001\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab1.\u4e0b\u8f7dGitLab\uff1a\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u8bf7\u5148\u4eceGitLab\u5b98\u65b9\u7f51\u7ad9\uff08https:\/\/about.gitlab.com\/install\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684GitLab\u8f6f\u4ef6\u5305\u3002 2.\u5b89\u88c5GitLab\uff1a\u5f53\u4e0b\u8f7dGitLab\u8f6f\u4ef6\u5305\u540e\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a \uff081\uff09\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\u4e4b\u524d\uff0c\u8bf7\u5148\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a &nbsp; sudo apt-get update &nbsp; sudo apt-get install -y curl openssh-server ca-certificates \uff082\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\uff1a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u8f6f\u4ef6\u5305\uff1a &nbsp; cd \/tmp &nbsp; curl -LO https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ee\/script.deb.sh &nbsp; sudo bash \/tmp\/script.deb.sh &nbsp; sudo EXTERNAL_URL=&#8221;http:\/\/gitlab.example.com&#8221; apt-get install gitlab-ee \u6ce8\uff1a\u5c06http:\/\/gitlab.example.com\u66ff\u6362\u4e3a\u60a8\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\u3002 \uff083\uff09\u6253\u5f00\u9632\u706b\u5899\u7aef\u53e3\uff1a\u8981\u8bbf\u95eeGitLab Web\u754c\u9762\uff0c\u60a8\u9700\u8981\u6253\u5f00GitLab\u6240\u9700\u7684\u7aef\u53e3\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGitLab\u9700\u8981\u6253\u5f00HTTP\uff0880\u7aef\u53e3\uff09\u548cHTTPS\uff08443\u7aef\u53e3\uff09\u7aef\u53e3\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u7aef\u53e3\uff1a sudo ufw allow httpsudo ufw allow https \uff084\uff09\u91cd\u542fGitLab\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u542fGitLab\uff1a &nbsp; sudo gitlab-ctl reconfigure \u4e09\u3001\u914d\u7f6eGitLab\u5728\u5b89\u88c5GitLab\u540e\uff0c\u60a8\u9700\u8981\u8fdb\u884c\u4e9b\u7b80\u5355\u7684\u8bbe\u7f6e\u6765\u914d\u7f6eGitLab\u3002\u4ee5\u4e0b\u662f\u5b8c\u6210\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u7684\u6b65\u9aa4\u3002 1.\u914d\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\uff1aGitLab\u9700\u8981SMTP\u90ae\u4ef6\u670d\u52a1\u6765\u53d1\u9001\u90ae\u4ef6\u7ed9\u7528\u6237\u3002\u60a8\u9700\u8981\u8bbe\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\u624d\u80fd\u5411\u7528\u6237\u53d1\u9001\u90ae\u4ef6\u3002\u53ef\u4ee5\u6309\u7167GitLab\u6587\u6863\uff08https:\/\/docs.gitlab.com\/omnibus\/settings\/smtp.html\uff09\u914d\u7f6eSMTP\u90ae\u4ef6\u670d\u52a1\u3002 [&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-18811","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18811","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=18811"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18811\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}