{"id":18833,"date":"2024-11-19T10:50:02","date_gmt":"2024-11-19T02:50:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18833\/"},"modified":"2024-11-19T10:50:02","modified_gmt":"2024-11-19T02:50:02","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e7%a6%bb%e7%ba%bf%e7%8e%af%e5%a2%83%e4%b8%8b%e5%ae%89%e8%a3%85gitlab","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18833\/","title":{"rendered":"\u5982\u4f55\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u5b89\u88c5GitLab"},"content":{"rendered":"<p>gitlab\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u57fa\u4e8eweb\u7684git\u5b58\u50a8\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u56e2\u961f\u6709\u6548\u5730\u8fdb\u884c\u4ee3\u7801\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5728\u5177\u6709\u826f\u597d\u7684\u4e92\u8054\u7f51\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c06gitlab\u5b89\u88c5\u5728\u672c\u5730\u670d\u52a1\u5668\u4e0a\u901a\u5e38\u662f\u6700\u4f73\u9009\u62e9\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u65e0\u6cd5\u8fde\u63a5\u5230\u4e92\u8054\u7f51\uff0c\u90a3\u4e48\u79bb\u7ebf\u5b89\u88c5gitlab\u5c31\u6210\u4e3a\u4e86\u5fc5\u987b\u7684\u9009\u62e9\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u5b89\u88c5gitlab\u3002<\/p>\n<ol>\n<li>\u4e0b\u8f7dGitLab\u6e90\u7801<\/li>\n<\/ol>\n<p>\u9996\u5148\uff0c\u9700\u8981\u4eceGitLab\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6e90\u7801\u3002\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u7279\u5b9a\u7684\u7248\u672c\uff0c\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002\u4e0b\u8f7d\u540e\uff0c\u5c06\u6e90\u7801\u5305\u62f7\u8d1d\u5230\u76ee\u6807\u673a\u5668\u7684\u672c\u5730\u5b58\u50a8\u6216\u8005\u6709\u8bbf\u95ee\u6743\u9650\u7684\u7f51\u7edc\u4f4d\u7f6e\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5\u4f9d\u8d56<\/li>\n<\/ol>\n<p>\u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u786e\u8ba4\u76ee\u6807\u673a\u5668\u4e0a\u662f\u5426\u5b89\u88c5\u4e86\u76f8\u5e94\u7684\u4f9d\u8d56\u9879\u3002GitLab\u9700\u8981\u4f9d\u8d56\u4ee5\u4e0b\u7684\u8f6f\u4ef6\u5305\u548c\u5e93\uff1a<\/p>\n<ul>\n<li>redis<\/li>\n<li>ruby<\/li>\n<li>postfix or sendmail (optional)<\/li>\n<li>build-essential<\/li>\n<li>libmysqlclient-dev<\/li>\n<\/ul>\n<p>\u5728\u4f7f\u7528apt-get\u8fdb\u884c\u5b89\u88c5\u4e4b\u524d\uff0c\u8981\u786e\u4fdd\u76ee\u6807\u673a\u5668\u80fd\u591f\u8fde\u63a5\u5230ubuntu\/Debian\u5b98\u65b9\u8f6f\u4ef6\u4ed3\u5e93\uff0c\u5426\u5219\u53ef\u4ee5\u5148\u4ece\u5916\u90e8\u4fdd\u5b58\u5230\u786c\u76d8\uff0c\u7136\u540e\u901a\u8fc7\u547d\u4ee4\u884c\u5b89\u88c5\u3002<\/p>\n<p>\u4f8b\u5982\uff1a\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n<pre>sudo apt-get update\nsudo apt-get install -y curl openssh-server ca-certificates tzdata perl<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u786e\u4fddGitLab\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\uff0c\u9700\u8981\u5bf9\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u8fdb\u884c\u914d\u7f6e\u3002\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>GITLAB_HOME &#8211; GitLab\u7684\u6839\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u50a8GitLab\u7684\u6570\u636e\u6587\u4ef6\u3002<\/li>\n<li>GITLAB_LOG_DIR &#8211; GitLab\u7684\u65e5\u5fd7\u76ee\u5f55\u3002<\/li>\n<li>GITLAB_BACKUP_DIR &#8211; GitLab\u7684\u5907\u4efd\u76ee\u5f55\u3002<\/li>\n<li>UNICORN_WORKERS &#8211; Unicorn\u7684\u5de5\u4f5c\u8fdb\u7a0b\u6570\u91cf\u3002<\/li>\n<li>SIDEKIQ_WORKERS &#8211; Sidekiq\u7684\u5de5\u4f5c\u8fdb\u7a0b\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p>\u5728Ubuntu\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u6dfb\u52a0\u5230\/etc\/profile\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre>export GITLAB_HOME=\/data\/gitlab\nexport GITLAB_LOG_DIR=\/var\/log\/gitlab\nexport GITLAB_BACKUP_DIR=\/var\/opt\/gitlab\/backups\nexport SIDEKIQ_WORKERS=4\nexport UNICORN_WORKERS=4<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u5b89\u88c5Ruby<\/li>\n<\/ol>\n<p>\u56e0\u4e3aGitLab\u662f\u7531Ruby on Rails\u7f16\u5199\u7684\uff0c\u6240\u4ee5\u9700\u8981\u5b89\u88c5Ruby\u3002\u53ef\u4ee5\u4eceRuby\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u7a33\u5b9a\u7248\u672c\u7684Ruby\u3002<\/p>\n<pre>curl -L https:\/\/get.rvm.io | bash -s stable\nsource ~\/.rvm\/scripts\/rvm\nrvm install 2.6.5\nrvm use 2.6.5 --default<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u5b89\u88c5GitLab<\/li>\n<\/ol>\n<p>\u73b0\u5728\uff0c\u53ef\u4ee5\u5f00\u59cb\u5b89\u88c5GitLab\u4e86\u3002\u9996\u5148\uff0c\u901a\u8fc7\u89e3\u538b\u7f29GitLab\u6e90\u4ee3\u7801\u5305\u6765\u5b89\u88c5GitLab\u3002\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\uff1a<\/p>\n<pre>tar zxvf gitlab-x_x_x.tar.gz\ncd gitlab-x_x_x\/<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\uff0c\u53ef\u4ee5\u8fd0\u884c\u547d\u4ee4\u8fdb\u884cGitLab\u7684\u914d\u7f6e\u548c\u5b89\u88c5\uff1a<\/p>\n<pre>sudo .\/configure --disable-absolute_paths_in_gitlab_yaml --disable-ssh --disable-postgresql --disable-geoip_database --disable-dependency-tracking\nsudo make install<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u914d\u7f6eGitLab<\/li>\n<\/ol>\n<p>\u5b89\u88c5\u540e\uff0c\u9700\u8981\u5bf9GitLab\u8fdb\u884c\u914d\u7f6e\u3002\u5728GitLab\u7684\u6e90\u4ee3\u7801\u4e2d\uff0c\u6709\u4e00\u4e2a\u540d\u4e3a\u201cgitlab.yml\u201d\u7684\u6587\u4ef6\uff0c\u5b83\u5305\u542bGitLab\u7684\u6240\u6709\u914d\u7f6e\u3002<\/p>\n<p>\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\uff0c\u9700\u8981\u505a\u4ee5\u4e0b\u51e0\u6b65\uff1a<\/p>\n<ul>\n<li>\u5c06\u8bbf\u95eeIP\u5730\u5740\u66f4\u6539\u4e3a\u5185\u90e8\u7f51\u7edcIP\u5730\u5740\u3002<\/li>\n<li>\u914d\u7f6eSMTP\u5730\u5740\uff0c\u4ee5\u4fbfGitLab\u80fd\u591f\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u3002<\/li>\n<li>\u914d\u7f6eGitLab\u7684\u4e3b\u6301\u540d\u548c\u4f20\u8f93\u534f\u8bae\uff08http\u6216https\uff09\u3002<\/li>\n<li>\u914d\u7f6eGitLab\u6570\u636e\u6587\u4ef6\u548c\u65e5\u5fd7\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u542fGitLab\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5SSL\u8bc1\u4e66<\/li>\n<\/ol>\n<p>\u6700\u540e\uff0c\u53ef\u4ee5\u4e3aGitLab\u8bbe\u7f6eSSL\u8bc1\u4e66\u3002\u5728\u8fd9\u91cc\uff0c\u9700\u8981\u4f7f\u7528\u5f00\u53d1\u81ea\u5df1\u7684\u8bc1\u4e66\uff0c\u56e0\u4e3a\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u65e0\u6cd5\u4f7f\u7528\u516c\u5171\u8bc1\u4e66\u9881\u53d1\u673a\u6784\uff08CA\uff09\u9881\u53d1\u7684\u8bc1\u4e66\u3002<\/p>\n<p>\u4f7f\u7528\u672c\u547d\u4ee4\u521b\u5efa\u81ea\u7b7e\u540d\u8bc1\u4e66\u548c\u5bc6\u94a5\uff1a<\/p>\n<pre>sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \/etc\/gitlab\/ssl\/gitlab.key -out \/etc\/gitlab\/ssl\/gitlab.crt<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u4ee5\u4e0b3\u884c\u6dfb\u52a0\u5230GitLab\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre>ssl_certificate \/etc\/gitlab\/ssl\/gitlab.crt;\nssl_certificate_key \/etc\/gitlab\/ssl\/gitlab.key;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6700\u540e\uff0c\u91cd\u542fGitLab\u5e76\u6d4b\u8bd5\u8fde\u63a5\u3002<\/p>\n<p>\u7ed3\u8bba<\/p>\n<p>GitLab\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u63d0\u4f9b\u4e86\u4ee3\u7801\u7ba1\u7406\u3001\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u7684\u4e00\u7cfb\u5217\u529f\u80fd\u3002\u5982\u679c\u4f60\u7684\u73af\u5883\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\uff0c\u90a3\u4e48\u79bb\u7ebf\u5b89\u88c5GitLab\u5c31\u6210\u4e3a\u4e86\u5fc5\u987b\u7684\u9009\u62e9\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u5b89\u88c5\u548c\u914d\u7f6eGitLab\uff0c\u8fd9\u5c06\u4f7f\u4f60\u80fd\u591f\u59cb\u7ec8\u638c\u63a7\u81ea\u5df1\u7684\u4ee3\u7801\u7ba1\u7406\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\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>gitlab\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u57fa\u4e8eweb\u7684git\u5b58\u50a8\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u56e2\u961f\u6709\u6548\u5730\u8fdb\u884c\u4ee3\u7801\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5728\u5177\u6709\u826f\u597d\u7684\u4e92\u8054\u7f51\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c06gitlab\u5b89\u88c5\u5728\u672c\u5730\u670d\u52a1\u5668\u4e0a\u901a\u5e38\u662f\u6700\u4f73\u9009\u62e9\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u65e0\u6cd5\u8fde\u63a5\u5230\u4e92\u8054\u7f51\uff0c\u90a3\u4e48\u79bb\u7ebf\u5b89\u88c5gitlab\u5c31\u6210\u4e3a\u4e86\u5fc5\u987b\u7684\u9009\u62e9\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728\u79bb\u7ebf\u73af\u5883\u4e0b\u5b89\u88c5gitlab\u3002 \u4e0b\u8f7dGitLab\u6e90\u7801 \u9996\u5148\uff0c\u9700\u8981\u4eceGitLab\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6e90\u7801\u3002\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u7279\u5b9a\u7684\u7248\u672c\uff0c\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002\u4e0b\u8f7d\u540e\uff0c\u5c06\u6e90\u7801\u5305\u62f7\u8d1d\u5230\u76ee\u6807\u673a\u5668\u7684\u672c\u5730\u5b58\u50a8\u6216\u8005\u6709\u8bbf\u95ee\u6743\u9650\u7684\u7f51\u7edc\u4f4d\u7f6e\u3002 \u5b89\u88c5\u4f9d\u8d56 \u5728\u5f00\u59cb\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u786e\u8ba4\u76ee\u6807\u673a\u5668\u4e0a\u662f\u5426\u5b89\u88c5\u4e86\u76f8\u5e94\u7684\u4f9d\u8d56\u9879\u3002GitLab\u9700\u8981\u4f9d\u8d56\u4ee5\u4e0b\u7684\u8f6f\u4ef6\u5305\u548c\u5e93\uff1a redis ruby postfix or sendmail (optional) build-essential libmysqlclient-dev \u5728\u4f7f\u7528apt-get\u8fdb\u884c\u5b89\u88c5\u4e4b\u524d\uff0c\u8981\u786e\u4fdd\u76ee\u6807\u673a\u5668\u80fd\u591f\u8fde\u63a5\u5230ubuntu\/Debian\u5b98\u65b9\u8f6f\u4ef6\u4ed3\u5e93\uff0c\u5426\u5219\u53ef\u4ee5\u5148\u4ece\u5916\u90e8\u4fdd\u5b58\u5230\u786c\u76d8\uff0c\u7136\u540e\u901a\u8fc7\u547d\u4ee4\u884c\u5b89\u88c5\u3002 \u4f8b\u5982\uff1a\u5728Ubuntu\u7cfb\u7edf\u4e0a\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff1a sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates tzdata perl \u767b\u5f55\u540e\u590d\u5236 \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf \u4e3a\u4e86\u786e\u4fddGitLab\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\uff0c\u9700\u8981\u5bf9\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u8fdb\u884c\u914d\u7f6e\u3002\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u5305\u62ec\uff1a GITLAB_HOME &#8211; GitLab\u7684\u6839\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u50a8GitLab\u7684\u6570\u636e\u6587\u4ef6\u3002 GITLAB_LOG_DIR &#8211; GitLab\u7684\u65e5\u5fd7\u76ee\u5f55\u3002 GITLAB_BACKUP_DIR &#8211; GitLab\u7684\u5907\u4efd\u76ee\u5f55\u3002 UNICORN_WORKERS &#8211; Unicorn\u7684\u5de5\u4f5c\u8fdb\u7a0b\u6570\u91cf\u3002 SIDEKIQ_WORKERS &#8211; Sidekiq\u7684\u5de5\u4f5c\u8fdb\u7a0b\u6570\u91cf\u3002 \u5728Ubuntu\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u6dfb\u52a0\u5230\/etc\/profile\u6587\u4ef6\u4e2d\uff1a export GITLAB_HOME=\/data\/gitlab export GITLAB_LOG_DIR=\/var\/log\/gitlab export GITLAB_BACKUP_DIR=\/var\/opt\/gitlab\/backups export SIDEKIQ_WORKERS=4 export [&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-18833","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18833","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=18833"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18833\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}