{"id":18867,"date":"2024-11-19T17:25:27","date_gmt":"2024-11-19T09:25:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18867\/"},"modified":"2024-11-19T17:25:27","modified_gmt":"2024-11-19T09:25:27","slug":"centos7-gitlab-%e5%ae%89%e8%a3%85%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18867\/","title":{"rendered":"CentOS7 Gitlab \u5b89\u88c5\u6307\u5357"},"content":{"rendered":"<p>centos7 gitlab \u5b89\u88c5\u6307\u5357<\/p>\n<p>\u6982\u8ff0<\/p>\n<p>GitLab \u662f\u4e00\u6b3e\u57fa\u4e8eGit\u7684Web\u754c\u9762\u7684Git\u4ee3\u7801\u6258\u7ba1\u548c\u4ee3\u7801\u5ba1\u67e5\u7684\u5f00\u6e90\u8f6f\u4ef6\u3002\u5b83\u5177\u6709\u7248\u672c\u63a7\u5236\u3001\u4ee3\u7801\u5ba1\u67e5\u3001\u534f\u4f5c\u7b49\u529f\u80fd\uff0c\u88ab\u8ba4\u4e3a\u662f GitHub \u7684\u5b8c\u7f8e\u66ff\u4ee3\u54c1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5728 CentOS7 \u4e0a\u5b89\u88c5 GitLab \u7684\u8fc7\u7a0b\u3002<\/p>\n<p>\u7cfb\u7edf\u8981\u6c42<\/p>\n<ul>\n<li>CentOS7 x64 \u7cfb\u7edf\uff0c\u5185\u5b58 2GB \u4ee5\u4e0a\uff1b<\/li>\n<li>\u5b89\u88c5\u5e76\u542f\u52a8 Nginx\uff1b<\/li>\n<li>\u5b89\u88c5\u5e76\u542f\u52a8 PostgreSQL\uff1b<\/li>\n<li>\u5b89\u88c5\u5e76\u542f\u52a8 Redis\uff1b<\/li>\n<li>\u5f00\u901a TCP \u7aef\u53e3 22,80,443\u3002<\/li>\n<\/ul>\n<p>\u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6\u5305<\/p>\n<p>\u4e3a\u4e86\u5b89\u88c5 GitLab\uff0c\u60a8\u9700\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u8f6f\u4ef6\u5305\u3002<\/p>\n<pre>sudo yum -y update\nsudo yum -y install curl openssh-server openssh-clients postfix cronie wget<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5b89\u88c5 GitLab<\/p>\n<pre>curl https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.rpm.sh | sudo bash\nsudo yum -y install gitlab-ce<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>GitLab \u542f\u52a8<\/p>\n<pre>sudo gitlab-ctl reconfigure<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u5b8c\u6210 GitLab \u7684\u5b89\u88c5\u8fc7\u7a0b\u4e4b\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 GitLab\uff1a<\/p>\n<pre>sudo gitlab-ctl start<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bbf\u95ee GitLab<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGitLab \u4f7f\u7528 HTTP \u534f\u8bae\u7684 80 \u7aef\u53e3\uff0c\u56e0\u4e3a\u5728\u5b89\u88c5 GitLab \u7684\u8fc7\u7a0b\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86 Nginx\uff0c\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u670d\u52a1\u5668\u7684 IP \u5730\u5740\u6216\u57df\u540d\u6765\u8bbf\u95ee\u60a8\u7684 GitLab \u5b9e\u4f8b\u3002<\/p>\n<pre>http:\/\/&lt;your-server-ip&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b2c\u4e00\u6b21\u8bbf\u95ee Gitlab<\/p>\n<p>\u5f53\u60a8\u7b2c\u4e00\u6b21\u8bbf\u95ee\u60a8\u7684 GitLab \u5b9e\u4f8b\u7684\u65f6\u5019\uff0c\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u7ba1\u7406\u5458\u5bc6\u7801\uff0c\u4ee5\u4fbf\u5728\u4e0b\u4e00\u6b21\u8bbf\u95ee\u65f6\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee GitLab \u5b9e\u4f8b\u65f6\uff0c\u4f1a\u81ea\u52a8\u5b9a\u5411\u5230\u5bc6\u7801\u8bbe\u7f6e\u9875\u9762\u3002\u8f93\u5165\u5bc6\u7801\u5e76\u70b9\u51fb &#8220;\u8bbe\u7f6e\u5bc6\u7801&#8221; \u6309\u94ae\u3002\u5bc6\u7801\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a\u5c0f\u5199\u5b57\u6bcd\u3001\u4e00\u4e2a\u5927\u5199\u5b57\u6bcd\u3001\u4e00\u4e2a\u6570\u5b57\u548c\u4e00\u4e2a\u975e\u5b57\u6bcd\u7684\u5b57\u7b26\uff0c\u957f\u5ea6\u81f3\u5c11\u4e3a 8 \u4e2a\u5b57\u7b26\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/068\/168024149865100.png\" class=\"aligncenter\" title=\"CentOS7 Gitlab \u5b89\u88c5\u6307\u5357\u63d2\u56fe\" alt=\"CentOS7 Gitlab \u5b89\u88c5\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<p>\u8bbe\u7f6e\u5bc6\u7801\u540e\uff0c\u4f1a\u81ea\u52a8\u5b9a\u5411\u5230\u767b\u5f55\u9875\u9762\uff0c\u4f7f\u7528\u60a8\u521a\u521a\u8bbe\u7f6e\u7684\u5bc6\u7801\u767b\u5f55\u5373\u53ef\u3002<\/p>\n<p>Nginx \u53cd\u4ee3<\/p>\n<p>Nginx \u53cd\u4ee3\u53ef\u4ee5\u52a0\u901f GitLab \u8fd0\u884c\u901f\u5ea6\u3002<\/p>\n<p>\u4fee\u6539 GitLab \u914d\u7f6e\u6587\u4ef6<\/p>\n<pre>sudo vim \/etc\/gitlab\/gitlab.rb<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u627e\u5230\u4e0b\u9762\u8fd9\u4e00\u884c\uff1a<\/p>\n<pre>external_url 'http:\/\/gitlab.example.com'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u5176\u4e2d\u7684 http:\/\/gitlab.example.com \u66f4\u6539\u4e3a\u60a8\u7684\u57df\u540d\u6216 IP \u5730\u5740\u3002\u7136\u540e\u5c06\u914d\u7f6e\u5199\u5165 GitLab\u3002<\/p>\n<pre>sudo gitlab-ctl reconfigure<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u914d\u7f6e Nginx<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Nginx \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre>sudo touch \/etc\/nginx\/conf.d\/gitlab.conf\nsudo vim \/etc\/nginx\/conf.d\/gitlab.conf<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>upstream gitlab-workhorse {\n  server 127.0.0.1:8181 fail_timeout=0;\n}\n\nserver {\n  listen 80;\n\n  # Replace with your domain name\n  server_name gitlab.example.com;\n  server_tokens off; ## Don't show the nginx version number, a security best practice\n\n  location \/ {\n    # Change this to the protocol you prefer\/require.\n    proxy_pass http:\/\/gitlab-workhorse;\n\n    # Enable websocket support\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection $connection_upgrade;\n\n    proxy_set_header Host $http_host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-Ssl on;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n    proxy_read_timeout 180;\n    proxy_send_timeout 180;\n  }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u91cc\u9762\u7684 gitlab.example.com \u66f4\u6539\u4e3a\u60a8\u7684 Nginx \u57df\u540d\u6216 IP\u3002<\/p>\n<p>\u91cd\u542f Nginx\u3002<\/p>\n<pre>sudo systemctl restart nginx.service<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bbf\u95ee GitLab \u754c\u9762\u3002<\/p>\n<pre>http:\/\/gitlab.example.com<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u5728 CentOS7 \u4e0a\u642d\u5efa GitLab \u4e0d\u96be\uff0c\u9075\u5faa\u4e0a\u8ff0\u6b65\u9aa4\u53ef\u4ee5\u5728\u77ed\u65f6\u95f4\u5185\u5b8c\u6210\u57fa\u672c\u5b89\u88c5\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u7ea7\u522b\u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u6309\u7167 GitLab \u5b98\u65b9\u6587\u6863\u4e2d\u63d0\u4f9b\u7684\u65b9\u5f0f\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<p>\u53c2\u8003\u6587\u732e<\/p>\n<ul>\n<li>[1] GitLab.com<\/li>\n<li>[2] GitLab Documentation<\/li>\n<li>[3] How to Install Gitlab, Nginx and SSL on CentOS 7<\/li>\n<li>[4] How To Install and Configure GitLab on CentOS 7<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fCentOS7 Gitlab \u5b89\u88c5\u6307\u5357\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>centos7 gitlab \u5b89\u88c5\u6307\u5357 \u6982\u8ff0 GitLab \u662f\u4e00\u6b3e\u57fa\u4e8eGit\u7684Web\u754c\u9762\u7684Git\u4ee3\u7801\u6258\u7ba1\u548c\u4ee3\u7801\u5ba1\u67e5\u7684\u5f00\u6e90\u8f6f\u4ef6\u3002\u5b83\u5177\u6709\u7248\u672c\u63a7\u5236\u3001\u4ee3\u7801\u5ba1\u67e5\u3001\u534f\u4f5c\u7b49\u529f\u80fd\uff0c\u88ab\u8ba4\u4e3a\u662f GitHub \u7684\u5b8c\u7f8e\u66ff\u4ee3\u54c1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5728 CentOS7 \u4e0a\u5b89\u88c5 GitLab \u7684\u8fc7\u7a0b\u3002 \u7cfb\u7edf\u8981\u6c42 CentOS7 x64 \u7cfb\u7edf\uff0c\u5185\u5b58 2GB \u4ee5\u4e0a\uff1b \u5b89\u88c5\u5e76\u542f\u52a8 Nginx\uff1b \u5b89\u88c5\u5e76\u542f\u52a8 PostgreSQL\uff1b \u5b89\u88c5\u5e76\u542f\u52a8 Redis\uff1b \u5f00\u901a TCP \u7aef\u53e3 22,80,443\u3002 \u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6\u5305 \u4e3a\u4e86\u5b89\u88c5 GitLab\uff0c\u60a8\u9700\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u8f6f\u4ef6\u5305\u3002 sudo yum -y update sudo yum -y install curl openssh-server openssh-clients postfix cronie wget \u767b\u5f55\u540e\u590d\u5236 \u5b89\u88c5 GitLab curl https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.rpm.sh | sudo bash sudo yum [&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-18867","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18867","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=18867"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18867\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}