{"id":5430,"date":"2020-08-14T17:43:21","date_gmt":"2020-08-14T09:43:21","guid":{"rendered":"http:\/\/39.97.231.10\/?p=5430"},"modified":"2020-08-14T17:43:21","modified_gmt":"2020-08-14T09:43:21","slug":"gitlab_%e6%9c%ac%e5%9c%b0gitlab%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=5430","title":{"rendered":"GitLab_\u672c\u5730GitLab\u670d\u52a1\u5668\u642d\u5efa"},"content":{"rendered":"<h1>GitLab \u662f\u4e00\u4e2a\u7528\u4e8e\u4ed3\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u4f7f\u7528<a href=\\\"https:\/\/baike.baidu.com\/item\/Git\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">Git<\/a>\u4f5c\u4e3a\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\uff0c\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u642d\u5efa\u8d77\u6765\u7684web\u670d\u52a1<\/h1>\n<div>\n<h3>\u7cfb\u7edf\u8981\u6c42<\/h3>\n<p>\u7cfb\u7edf\uff1acentos7 x86_64 (\u5fc5\u987b\u898164\u4f4d\u7cfb\u7edf\uff0c32\u4f4d\u7cfb\u7edf\u4e0d\u80fd\u5b89\u88c5gitlab)<br \/>\n\u5185\u5b58\uff1a4G<br \/>\n\u786c\u76d8\uff1a10G\u5c31\u5dee\u4e0d\u591a\u4e86\uff0c\u6ca1\u6709\u8981\u6c42<\/p>\n<h3>Gitlab\u4e0b\u8f7d<\/h3>\n<p>\u5b98\u7f51\uff1a<a href=\\\"https:\/\/about.gitlab.com\/installation\/#centos-7\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">https:\/\/about.gitlab.com\/installation\/#centos-7<\/a><br \/>\n\u7531\u4e8e\u5b98\u7f51\u5f88\u6162\uff0c\u6545\u7528\u56fd\u5185\u7684\u955c\u50cf\u6e90\uff1a<a href=\\\"https:\/\/mirrors.tuna.tsinghua.edu.cn\/gitlab-ce\/yum\/el7\/\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">https:\/\/mirrors.tuna.tsinghua.edu.cn\/gitlab-ce\/yum\/el7\/<\/a><br \/>\n\u76ee\u524drpm\u5305\u6700\u65b0\u7248\u672c\uff1a<a href=\\\"https:\/\/mirrors.tuna.tsinghua.edu.cn\/gitlab-ce\/yum\/el7\/gitlab-ce-10.5.1-ce.0.el7.x86_64.rpm\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">gitlab-ce-10.5.1-ce.0.el7.x86_64.rpm<\/a><\/p>\n<h3>\u5b89\u88c5<\/h3>\n<p>\u5b98\u65b9\u8bf4\u660e\uff1a<\/p>\n<h4>1. Install and configure the necessary dependencies<\/h4>\n<p>On CentOS 7 (and RedHat\/Oracle\/Scientific Linux 7), the commands below will also open HTTP and SSH access in the system firewall.<\/p>\n<pre>sudo yum install -y curl policycoreutils-python openssh-server\nsudo systemctl enable sshd\nsudo systemctl start sshd\nsudo firewall-cmd --permanent --add-service=http\nsudo systemctl reload firewalld<\/pre>\n<p>Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and\u00a0<a href=\\\"https:\/\/docs.gitlab.com\/omnibus\/settings\/smtp.html\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">configure an external SMTP server<\/a>\u00a0after GitLab has been installed.<\/p>\n<pre>sudo yum install postfix\nsudo systemctl enable postfix\nsudo systemctl start postfix<\/pre>\n<p>During Postfix installation a configuration screen may appear. Select \\&#8217;Internet Site\\&#8217; and press enter. Use your server\\&#8217;s external DNS for \\&#8217;mail name\\&#8217; and press enter. If additional screens appear, continue to press enter to accept the defaults.<\/p>\n<h4>2. Add the GitLab package repository and install the package<\/h4>\n<h5>\u5728\u7ebf\u5b89\u88c5<\/h5>\n<p>Add the GitLab package repository.<\/p>\n<pre>curl https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ee\/script.rpm.sh | sudo bash<\/pre>\n<p>Next, install the GitLab package. Change\u00a0http:\/\/gitlab.example.com\u00a0to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL. HTTPS requires\u00a0<a href=\\\"https:\/\/docs.gitlab.com\/omnibus\/settings\/nginx.html#enable-https\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">additional configuration<\/a>\u00a0after installation.<\/p>\n<pre>sudo EXTERNAL_URL=\\\"http:\/\/gitlab.example.com\\\" yum install -y gitlab-ee<\/pre>\n<h5>\u79bb\u7ebfrpm\u5305\u5b89\u88c5<\/h5>\n<p>\u7531\u4e8e\u5728\u7ebf\u5b89\u88c5\u5f88\u6162\uff0c\u6545\u4f7f\u7528\u4e0a\u9762\u4e0b\u8f7d\u7684rpm\u5305\u5b89\u88c5<\/p>\n<pre>rpm -ivh gitlab-ce-10.5.1-ce.0.el7.x86_64.rpm<\/pre>\n<h4>3.Configure and start GitLab<\/h4>\n<pre>sudo gitlab-ctl reconfigure<\/pre>\n<h3>4.Browse to the hostname and login<\/h3>\n<p>On your first visit, you\u2019ll be redirected to a password reset screen to provide the password for the initial administrator account. Enter your desired password and you\u2019ll be redirected back to the login screen.<br \/>\nThe default account\u2019s username is root. Provide the password you created earlier and login. After login you can change the username if you wish.<br \/>\nFor configuration and troubleshooting options please see the Omnibus GitLab documentation<br \/>\nIf you are located in China, try using\u00a0<a href=\\\"https:\/\/mirror.tuna.tsinghua.edu.cn\/help\/gitlab-ce\/\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">https:\/\/mirror.tuna.tsinghua.edu.cn\/help\/gitlab-ce\/<\/a><\/p>\n<h3>\u95ee\u9898<\/h3>\n<h4>\u51fa\u73b0\u9875\u9762502<\/h4>\n<p>\u539f\u56e0\uff1a\u7531\u4e8eunicorn\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f8080\u7aef\u53e3\uff0c\u53ef\u80fd\u6709\u5176\u4ed6\u7a0b\u5e8f\u5360\u7528\u4e868080\u7aef\u53e3\u3002<br \/>\n\u89e3\u51b3\u529e\u6cd5\uff1a\u6253\u5f00\/etc\/gitlab\/gitlab.rb,\u6253\u5f00# unicorn[\u2018port\u2019] = 8080 \u7684\u6ce8\u91ca\uff0c\u5c068080\u4fee\u6539\u4e3a9090\uff0c\u4fdd\u5b58\u540e\u8fd0\u884c<\/p>\n<pre>sudo gitlab-ctl reconfigure<\/pre>\n<p>\u4fee\u6539\u9ed8\u8ba480\u7aef\u53e3<\/p>\n<pre>vim \/etc\/gitlab\/gitlab.rb<\/pre>\n<p>\u4fee\u6539external_url \u2018<a href=\\\"http:\/\/localhost:8888\/\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">http:\/\/localhost:8888<\/a>\u2019 \u4fdd\u5b58\u9000\u51fa\u3002<br \/>\n\u5237\u65b0\u914d\u7f6e\uff1a<\/p>\n<pre>sudo gitlab-ctl reconfigure<\/pre>\n<p>\u5982\u679c\u7aef\u53e3\u4fee\u6539\u540e\u65e0\u6cd5\u8bbf\u95ee\uff0c\u8bf7\u68c0\u67e5\u9632\u706b\u5899\u662f\u5426\u5173\u95ed\u3002<br \/>\n\u53e6\u9644gitlab\u91cd\u542f\u547d\u4ee4\uff08\u53ef\u4ee5\u4e0d\u6267\u884c\uff09\u3002<\/p>\n<pre>sudo gitlab-ctl restart<\/pre>\n<h3>\u914d\u7f6e\u90ae\u4ef6\u53d1\u9001<\/h3>\n<p>\u5b98\u65b9\u8bf4\u660e\uff1a<a href=\\\"https:\/\/docs.gitlab.com\/omnibus\/settings\/smtp.html\\\" target=\\\"_blank\\\" rel=\\\"nofollow noopener noreferrer\\\">https:\/\/docs.gitlab.com\/omnibus\/settings\/smtp.html<\/a><br \/>\n\u4fee\u6539gitlab.rb<br \/>\nsudo vi \/etc\/gitlab\/gitlab.rb<\/p>\n<pre>gitlab_rails[\\'smtp_enable\\'] = true\ngitlab_rails[\\'smtp_address\\'] = \\\"smtp.server\\\"\ngitlab_rails[\\'smtp_port\\'] = 465\ngitlab_rails[\\'smtp_user_name\\'] = \\\"smtp user\\\"\ngitlab_rails[\\'smtp_password\\'] = \\\"smtp password\\\"\ngitlab_rails[\\'smtp_domain\\'] = \\\"example.com\\\"\ngitlab_rails[\\'smtp_authentication\\'] = \\\"login\\\"\ngitlab_rails[\\'smtp_enable_starttls_auto\\'] = true\ngitlab_rails[\\'smtp_openssl_verify_mode\\'] = \\'peer\\'\n# If your SMTP server does not like the default \\'From: gitlab@localhost\\' you\n# can change the \\'From\\' with this setting.\ngitlab_rails[\\'gitlab_email_from\\'] = \\'gitlab@example.com\\'\ngitlab_rails[\\'gitlab_email_reply_to\\'] = \\'noreply@example.com\\'<\/pre>\n<p>SMTP without SSL<\/p>\n<pre>gitlab_rails[\\'smtp_enable\\'] = true;\ngitlab_rails[\\'smtp_address\\'] = \\'localhost\\';\ngitlab_rails[\\'smtp_port\\'] = 25;\ngitlab_rails[\\'smtp_domain\\'] = \\'localhost\\';\ngitlab_rails[\\'smtp_tls\\'] = false;\ngitlab_rails[\\'smtp_openssl_verify_mode\\'] = \\'none\\'\ngitlab_rails[\\'smtp_enable_starttls_auto\\'] = false\ngitlab_rails[\\'smtp_ssl\\'] = false\ngitlab_rails[\\'smtp_force_ssl\\'] = false<\/pre>\n<p>\u4fee\u6539\u5b8c\uff0c\u91cd\u65b0\u914d\u7f6e<br \/>\nsudo gitlab-ctl reconfigure<br \/>\n\u67e5\u770b\u65e5\u5fd7<br \/>\nsudo gitlab-ctl tail<\/p>\n<h3>\u65e5\u5fd7\u67e5\u770b<\/h3>\n<p>unicorn\u65e5\u5fd7\u67e5\u770b\uff1agitlab-ctl tail unicorn<br \/>\ngitlab\u65e5\u5fd7\u67e5\u770b\uff1agitlab-ctl tail<\/p>\n<h3>gitlab\u6c49\u5316<\/h3>\n<h4>\u505c\u6b62gitlab<\/h4>\n<p>gitlab-ctl stop<\/p>\n<h4>\u67e5\u770b\u7248\u672c<\/h4>\n<pre>cat \/opt\/gitlab\/embedded\/service\/gitlab-rails\/VERSION\n10.5.1\nyum -y install git<\/pre>\n<h4>\u514b\u9686\u83b7\u53d6\u6c49\u5316\u7248\u672c\u5e93<\/h4>\n<p>git clone https:\/\/gitlab.com\/xhang\/gitlab.git<\/p>\n<h4>\u67e5\u770b\u8be5\u6c49\u5316\u8865\u4e01\u7684\u7248\u672c<\/h4>\n<pre>cat gitlab\/VERSION\n10.5.1<\/pre>\n<h4>\u6253\u6c49\u5316\u8865\u4e01<\/h4>\n<pre>cd \/root\/gitlab\/\ngit diff v10.5.1 v10.5.1-zh &gt;\/tmp\/10.5.1-zh.diff\nyum install patch -y\npatch -d \/opt\/gitlab\/embedded\/service\/gitlab-rails -p1 &lt; \/tmp\/10.5.1-zh.diff<\/pre>\n<h4>\u542f\u52a8gitlab<\/h4>\n<p>gitlab-ctl start<\/p>\n<h4>\u91cd\u65b0\u914d\u7f6egitlab<\/h4>\n<p>gitlab-ctl reconfigure<\/p>\n<h3>git\u4ed3\u5e93\u8fc1\u79fb<\/h3>\n<p>\u4f7f\u7528git push &#8211;mirror\u547d\u4ee4\u8fc1\u79fb\u4ed3\u5e93\u800c\u4e0d\u4e22\u5931log<br \/>\n\u5148\u4e86\u89e3\u4e00\u4e9bgit\u7684\u57fa\u672c\u53c2\u6570\u4ecb\u7ecd<br \/>\ngit clone &#8211;bare<\/p>\n<pre>GIT-CLONE(1)                      Git Manual                      GIT-CLONE(1)\nNAME\n       git-clone - Clone a repository into a new directory\nSYNOPSIS\n       git clone [--template=&lt;template_directory&gt;]\n                 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n                 [-o &lt;name&gt;] [-b &lt;name&gt;] [-u &lt;upload-pack&gt;] [--reference &lt;repository&gt;]\n                 [--depth &lt;depth&gt;] [--recursive] [--] &lt;repository&gt; [&lt;directory&gt;]\n        --bare\n            Make a bare GIT repository. That is, instead of creating &lt;directory&gt; and placing the administrative files\n           in &lt;directory&gt;\/.git, make the &lt;directory&gt; itself the $GIT_DIR. This obviously implies the -n because there\n           is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to\n           corresponding local branch heads, without mapping them to refs\/remotes\/origin\/. When this option is used,\n           neither remote-tracking branches nor the related configuration variables are created.<\/pre>\n<p>git push &#8211;mirror<\/p>\n<pre>--mirror\n           Instead of naming each ref to push, specifies that all refs under refs\/ (which includes but is not limited\n           to refs\/heads\/, refs\/remotes\/, and refs\/tags\/) be mirrored to the remote repository. Newly created local\n           refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and\n           deleted refs will be removed from the remote end. This is the default if the configuration option\n           remote.&lt;remote&gt;.mirror is set.<\/pre>\n<ul>\n<li>\u514b\u9686\u4ee3\u7801\u5e93<\/li>\n<\/ul>\n<p>git clone &#8211;bare git:\/\/192.168.10.XX\/git_repo\/project_name.git<\/p>\n<ul>\n<li>\u7136\u540e\u5230\u65b0\u7684 Git \u670d\u52a1\u5668\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u6bd4\u5982 GitCafe\uff0c\u4ea6\u6216\u662f\u672c\u5730\u7684\u79c1\u6709\u4ed3\u5e93\uff0c\u5982192.168.20.XX\n<pre>su - git\ncd \/path\/to\/path\/\nmkdir new_project_name.git\ngit init --bare new_project_name.git<\/pre>\n<\/li>\n<li>\u4ee5\u955c\u50cf\u63a8\u9001\u7684\u65b9\u5f0f\u4e0a\u4f20\u4ee3\u7801\u5230 GitCafe \u670d\u52a1\u5668\u4e0a\u3002\u8bf7\u786e\u4fdd\u5df2\u7ecf\u6dfb\u52a0\u4e86\u516c\u94a5\u5230\u65b0\u7684\u673a\u5668\u4e0a\u3002<\/li>\n<\/ul>\n<pre>cd project_name.git\ngit push --mirror git@192.168.20.XX\/path\/to\/path\/new_project_name.git<\/pre>\n<ul>\n<li>\u5220\u9664\u672c\u5730\u4ee3\u7801<\/li>\n<\/ul>\n<pre>cd ..\nrm -rf project_name.git<\/pre>\n<ul>\n<li>\u5230\u65b0\u670d\u52a1\u5668\u4e0a\u627e\u5230 Clone \u5730\u5740\uff0c\u76f4\u63a5Clone\u5230\u672c\u5730\u5c31\u53ef\u4ee5\u4e86\u3002<\/li>\n<\/ul>\n<pre>git clone git@192.168.20.XX\/path\/to\/path\/new_project_name.git<\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u4fdd\u7559\u539f\u7248\u672c\u5e93\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u3002\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>GitLab \u662f\u4e00\u4e2a\u7528\u4e8e\u4ed3\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u4f7f\u7528Git\u4f5c\u4e3a\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\uff0c\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u642d\u5efa\u8d77\u6765\u7684web\u670d\u52a1  &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=5430\"> <span class=\"screen-reader-text\">GitLab_\u672c\u5730GitLab\u670d\u52a1\u5668\u642d\u5efa<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[132,103],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"GitLab \u662f\u4e00\u4e2a\u7528\u4e8e\u4ed3\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u4f7f\u7528Git\u4f5c\u4e3a\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\uff0c\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u642d\u5efa\u8d77\u6765\u7684web\u670d\u52a1 &hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5430"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5430"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5430\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5430"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}