{"id":43950,"date":"2024-10-06T11:44:13","date_gmt":"2024-10-06T03:44:13","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43950\/"},"modified":"2024-10-06T11:44:13","modified_gmt":"2024-10-06T03:44:13","slug":"centos-8-%e5%ae%89%e8%a3%9d-gogs-%e6%89%98%e7%ae%a1%e6%9c%8d%e5%8b%99","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43950\/","title":{"rendered":"CentOS 8 \u5b89\u88dd Gogs \u6258\u7ba1\u670d\u52d9"},"content":{"rendered":"<h1 id=\"centos-8-%e5%ae%89%e8%a3%9d-gogs-%e6%89%98%e7%ae%a1%e6%9c%8d%e5%8b%99-sLcwRBJBoM\">CentOS 8 \u5b89\u88dd Gogs \u6258\u7ba1\u670d\u52d9<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u958b\u767c\u74b0\u5883\u4e2d\uff0c\u4ee3\u78bc\u6258\u7ba1\u670d\u52d9\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002Gogs \u662f\u4e00\u500b\u8f15\u91cf\u7d1a\u7684\u81ea\u8a17\u7ba1 Git \u670d\u52d9\uff0c\u9069\u5408\u958b\u767c\u8005\u548c\u5718\u968a\u4f7f\u7528\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd Gogs\uff0c\u8b93\u60a8\u80fd\u5920\u8f15\u9b06\u5730\u7ba1\u7406\u548c\u6258\u7ba1\u60a8\u7684\u4ee3\u78bc\u5eab\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-sLcwRBJBoM\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684 CentOS 8 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo dnf update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305\uff0c\u5305\u62ec Git \u548c SQLite\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo dnf install git sqlite sqlite-devel -y<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89-gogs-sLcwRBJBoM\">\u4e0b\u8f09 Gogs<\/h2>\n<p>Gogs \u7684\u6700\u65b0\u7248\u672c\u53ef\u4ee5\u5f9e\u5176\u5b98\u65b9 GitHub \u9801\u9762\u4e0b\u8f09\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u8f09 Gogs\uff1a<\/p>\n<pre><code>wget https:\/\/github.com\/gogs\/gogs\/releases\/download\/v0.13.0\/gogs_0.13.0_linux_amd64.tar.gz<\/code><\/pre>\n<p>\u4e0b\u8f09\u5b8c\u6210\u5f8c\uff0c\u89e3\u58d3\u7e2e\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar -zxvf gogs_0.13.0_linux_amd64.tar.gz<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-gogs-sLcwRBJBoM\">\u914d\u7f6e Gogs<\/h2>\n<p>\u89e3\u58d3\u7e2e\u5f8c\uff0c\u60a8\u6703\u770b\u5230\u4e00\u500b\u540d\u70ba gogs \u7684\u6587\u4ef6\u593e\u3002\u9032\u5165\u8a72\u6587\u4ef6\u593e\u4e26\u5275\u5efa\u4e00\u500b\u65b0\u7684\u7528\u6236\u4f86\u904b\u884c Gogs\uff1a<\/p>\n<pre><code>sudo useradd -m gogs<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5c07 Gogs \u7684\u6587\u4ef6\u593e\u7684\u64c1\u6709\u6b0a\u8f49\u79fb\u7d66\u65b0\u7528\u6236\uff1a<\/p>\n<pre><code>sudo chown -R gogs:gogs gogs<\/code><\/pre>\n<h2 id=\"%e8%a8%ad%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab-sLcwRBJBoM\">\u8a2d\u7f6e\u6578\u64da\u5eab<\/h2>\n<p>Gogs \u652f\u6301\u591a\u7a2e\u6578\u64da\u5eab\uff0c\u9019\u88e1\u6211\u5011\u5c07\u4f7f\u7528 SQLite\u3002\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u6578\u64da\u5eab\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo mkdir -p \/var\/lib\/gogs\/data\nsudo touch \/var\/lib\/gogs\/data\/gogs.db\nsudo chown gogs:gogs \/var\/lib\/gogs\/data\/gogs.db<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-gogs-sLcwRBJBoM\">\u555f\u52d5 Gogs<\/h2>\n<p>\u5728\u555f\u52d5 Gogs \u4e4b\u524d\uff0c\u60a8\u9700\u8981\u914d\u7f6e\u5176\u8a2d\u7f6e\u3002\u9032\u5165 Gogs \u7684\u76ee\u9304\uff0c\u7136\u5f8c\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo -u gogs .\/gogs web<\/code><\/pre>\n<p>\u9019\u5c07\u555f\u52d5 Gogs \u670d\u52d9\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u700f\u89bd\u5668\u8a2a\u554f <a href=\"http:\/\/your_server_ip:3000\" rel=\"nofollow\">http:\/\/your_server_ip:3000<\/a> \u4f86\u9032\u884c\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-gogs-%e7%b6%b2%e9%a0%81%e7%95%8c%e9%9d%a2-sLcwRBJBoM\">\u914d\u7f6e Gogs \u7db2\u9801\u754c\u9762<\/h2>\n<p>\u5728\u7db2\u9801\u754c\u9762\u4e2d\uff0c\u60a8\u9700\u8981\u586b\u5beb\u6578\u64da\u5eab\u8a2d\u7f6e\u3001\u7ba1\u7406\u54e1\u8cec\u6236\u4fe1\u606f\u7b49\u3002\u6839\u64da\u63d0\u793a\u5b8c\u6210\u8a2d\u7f6e\u5f8c\uff0c\u60a8\u5c31\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528 Gogs \u4f86\u7ba1\u7406\u60a8\u7684\u4ee3\u78bc\u5eab\u4e86\u3002<\/p>\n<h2 id=\"%e8%a8%ad%e7%bd%ae%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95-sLcwRBJBoM\">\u8a2d\u7f6e\u81ea\u52d5\u555f\u52d5<\/h2>\n<p>\u70ba\u4e86\u8b93 Gogs \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b systemd \u670d\u52d9\u55ae\u5143\u6587\u4ef6\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5275\u5efa\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/systemd\/system\/gogs.service<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[Unit]\nDescription=Gogs\nAfter=network.target\n\n[Service]\nUser=gogs\nGroup=gogs\nWorkingDirectory=\/path\/to\/gogs\nExecStart=\/path\/to\/gogs\/gogs web\nRestart=always\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u555f\u7528\u4e26\u555f\u52d5 Gogs \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl enable gogs\nsudo systemctl start gogs<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-sLcwRBJBoM\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u4e86 Gogs \u6258\u7ba1\u670d\u52d9\u3002\u9019\u4e0d\u50c5\u80fd\u5920\u5e6b\u52a9\u60a8\u66f4\u597d\u5730\u7ba1\u7406\u4ee3\u78bc\uff0c\u9084\u80fd\u63d0\u9ad8\u5718\u968a\u7684\u5354\u4f5c\u6548\u7387\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u74b0\u5883\u4f86\u904b\u884c Gogs\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u9805\u76ee\u63d0\u4f9b\u66f4\u597d\u7684\u652f\u6301\u548c\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd Gogs\uff0c\u8f15\u9b06\u642d\u5efa\u81ea\u6211\u6258\u7ba1\u7684 Git \u670d\u52d9\uff0c\u63d0\u5347\u7248\u672c\u63a7\u5236\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43950","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43950"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43950\/revisions"}],"predecessor-version":[{"id":43951,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43950\/revisions\/43951"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}