{"id":18949,"date":"2024-11-19T16:43:48","date_gmt":"2024-11-19T08:43:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18949\/"},"modified":"2024-11-19T16:43:48","modified_gmt":"2024-11-19T08:43:48","slug":"linux%e4%b8%8b%e6%80%8e%e4%b9%88%e9%80%9a%e8%bf%87gogs%e6%90%ad%e5%bb%ba%e8%87%aa%e5%b7%b1%e7%9a%84github","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18949\/","title":{"rendered":"Linux\u4e0b\u600e\u4e48\u901a\u8fc7Gogs\u642d\u5efa\u81ea\u5df1\u7684Github"},"content":{"rendered":"<p>\u968f\u7740github\u7684\u9010\u6e10\u666e\u53ca\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4f1a\u9009\u62e9\u5728\u5176\u4e2d\u5efa\u7acb\u81ea\u5df1\u7684\u9879\u76ee\uff0c\u4e5f\u5c31\u662f\u5728github\u4e0a\u53d1\u8868\u81ea\u5df1\u7684\u4ee3\u7801\u3002\u7136\u800c\uff0cgithub\u9650\u5236\u4e86\u5355\u4e2a\u8d26\u6237\u4e0a\u80fd\u5efa\u7acb\u7684\u79c1\u4eba\u5e93\u7684\u6570\u91cf\uff0c\u6240\u4ee5\u4e00\u4e9b\u9ad8\u9891\u4f7f\u7528\u8005\u53ef\u80fd\u9700\u8981\u901a\u8fc7\u5176\u4ed6\u9014\u5f84\u6765\u5efa\u7acb\u81ea\u5df1\u7684\u4ee3\u7801\u5e93\u3002\u5728\u8fd9\u4e2a\u65f6\u5019\uff0c\u81ea\u5df1\u642d\u5efagithub\u5c31\u6210\u4e3a\u4e86\u4e00\u4e2a\u9009\u62e9\u3002\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5728linux\u7cfb\u7edf\u4e0b\uff0c\u901a\u8fc7gogs\u642d\u5efa\u81ea\u5df1\u7684github\uff0c\u4ee5\u89e3\u653egithub\u8d26\u6237\u7684\u9650\u5236\u3002<\/p>\n<p><strong>\u4e00\u3001\u5b89\u88c5\u73af\u5883<\/strong><\/p>\n<p>\u5728\u5f00\u59cb\u642d\u5efa\u524d\uff0c\u9700\u8981\u786e\u4fdd\u7cfb\u7edf\u5b89\u88c5\u4e86\u76f8\u5e94\u7684\u73af\u5883\uff1a<\/p>\n<ol>\n<li>MySQL or PostgreSQL<\/li>\n<li>Go &gt;= 1.12.x<\/li>\n<li>Git &gt;= 1.7.1 (2.x recommended)<\/li>\n<\/ol>\n<p>\u5bf9\u4e8eUbuntu\u7cfb\u7edf\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5MySQL\uff1a<\/p>\n<pre>sudo apt-get update\nsudo apt-get install mysql-server<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>Go\u7684\u5b89\u88c5\u65b9\u5f0f\u53ef\u4ee5\u5728\u5b98\u7f51\u4e2d\u4e0b\u8f7d\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u5e76\u6309\u7167\u8bf4\u660e\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p>\u5bf9\u4e8e\u67d0\u4e9b\u7248\u672c\u7684Ubuntu\u6216Debian\u7cfb\u7edf\uff0c\u53ef\u80fd\u6ca1\u6709\u5b89\u88c5git-core\uff0c\u9700\u8981\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<pre>sudo apt-get update\nsudo apt-get install git-core<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4e8c\u3001\u5b89\u88c5Gogs<\/strong><\/p>\n<ol>\n<li>\u4eceGithub\u4e0a\u4e0b\u8f7dGogs\u7684\u6700\u65b0\u7248\u672c\u5e76\u89e3\u538b\u5230\u8be5\u76ee\u5f55\u4e0b\uff1a<\/li>\n<\/ol>\n<pre>wget https:\/\/dl.gogs.io\/gogs_latest_linux_amd64.tar.gz\ntar xvfz gogs_latest_linux_amd64.tar.gz<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u8fdb\u5165\u4e0b\u8f7d\u7684Gogs\u76ee\u5f55\uff0c\u6267\u884c\u5b89\u88c5\uff1a<\/li>\n<\/ol>\n<pre>cd gogs\n.\/gogs install<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u6267\u884c\u5b89\u88c5\u65f6\u9700\u8981\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>Do you want to install as Windows service\/daemon? (y\/n)\nn<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>Please enter the URL: (e.g. http:\/\/domain.com[:port] or http:\/\/[IP]:[port])\nhttp:\/\/localhost:3000<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u63a5\u4e0b\u6765\u7684\u5b89\u88c5\u6b65\u9aa4\u4f1a\u8981\u6c42\u8f93\u5165\u4e00\u4e9b\u6570\u636e\u5e93\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u9700\u8981\u4f60\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u914d\u7f6e\u3002\u8fd9\u91cc\u5efa\u8bae\u4f7f\u7528MySQL\u4f5c\u4e3a\u6570\u636e\u5e93\uff0c\u5e76\u5728\u8fd9\u4e00\u6b65\u4e2d\u5b89\u88c5\u7b2c2\u53f0\u670d\u52a1\u5668\u3002<\/p>\n<p>\u5728\u9700\u8981\u586b\u5199Git\u4fe1\u606f\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u5c06\u4f7f\u7528\u7684ssh-key\u6dfb\u52a0\u5230GitHub\u4e0a\u3002<\/p>\n<ol>\n<li>\u542f\u52a8Gogs\uff1a<\/li>\n<\/ol>\n<pre>cd gogs\n.\/gogs web<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6210\u529f\u542f\u52a8\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eehttp:\/\/localhost:3000\u3002<\/p>\n<p><strong>\u4e09\u3001\u914d\u7f6eNginx\u53cd\u5411\u4ee3\u7406<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u7684Gogs\u5b9e\u4f8b\u4f4d\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u5efa\u8bae\u4f7f\u7528Nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5Nginx\uff1a<\/li>\n<\/ol>\n<pre>sudo apt install nginx<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2avhost\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<pre>sudo nano \/etc\/nginx\/sites-available\/gogs<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u5176\u4e2d\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>server {\n    listen 80;\n\n    server_name git.example.com; # your domain name\n\n    access_log \/var\/log\/nginx\/git.access.log;\n    error_log \/var\/log\/nginx\/git.error.log;\n\n    location \/ {\n        proxy_pass http:\/\/localhost:3000;\n        proxy_set_header Host $http_host;\n    }\n\n    location \/ws {\n        proxy_pass http:\/\/localhost:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n    }\n\n    location ~ \/. {\n        deny all;\n    }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u66f4\u6539server_name\u3002<\/p>\n<ol>\n<li>\u786e\u4fddNginx\u89e3\u6790\u8be5vhost\uff1a<\/li>\n<\/ol>\n<pre>sudo ln -s \/etc\/nginx\/sites-available\/gogs \/etc\/nginx\/sites-enabled\/<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u91cd\u65b0\u52a0\u8f7dNginx\u914d\u7f6e\uff1a<\/p>\n<pre>sudo nginx -t\nsudo systemctl reload nginx<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u73b0\u5728\u4f60\u4fbf\u53ef\u4ee5\u5728\u4f60\u7684Webbrowser\u91cc\u6253\u5f00\u4f60\u7684\u7f51\u7ad9\uff0c\u901a\u8fc7 GitHub OAuth \u767b\u5f55\u3002<\/p>\n<p><strong>\u56db\u3001\u603b\u7ed3<\/strong><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u901a\u8fc7Gogs\u642d\u5efa\u81ea\u5df1\u7684Github\u8d26\u6237\u7684\u65b9\u6cd5\u3002\u76f8\u4fe1\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\u4e5f\u4f1a\u9047\u5230\u4e00\u4e9b\u7ec6\u8282\u95ee\u9898\uff0c\u4f46\u5927\u4f53\u4e0a\u64cd\u4f5c\u8fd8\u662f\u7b80\u5355\u6613\u61c2\u7684\u3002\u8fd9\u4e9b\u7ec6\u8282\u95ee\u9898\u53ef\u4ee5\u4e0a\u5b98\u65b9\u6587\u6863\u6216\u8005\u8bba\u575b\u5bfb\u6c42\u5e2e\u52a9\u3002\u81ea\u5df1\u642d\u5efaGithub\u4e0d\u4ec5\u53ef\u4ee5\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u7ba1\u7406\uff0c\u8fd8\u53ef\u4ee5\u6210\u4e3a\u5b66\u4e60\u7684\u8fc7\u7a0b\uff0c\u5177\u6709\u5f00\u53d1\u8005\u7684\u5de5\u5177\u4f7f\u5f97\u5b83\u53ef\u4f5c\u4e3a\u4e00\u4e2a\u5b66\u4e60\u6027\u8d28\u7684\u9879\u76ee\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux\u4e0b\u600e\u4e48\u901a\u8fc7Gogs\u642d\u5efa\u81ea\u5df1\u7684Github\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>\u968f\u7740github\u7684\u9010\u6e10\u666e\u53ca\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4f1a\u9009\u62e9\u5728\u5176\u4e2d\u5efa\u7acb\u81ea\u5df1\u7684\u9879\u76ee\uff0c\u4e5f\u5c31\u662f\u5728github\u4e0a\u53d1\u8868\u81ea\u5df1\u7684\u4ee3\u7801\u3002\u7136\u800c\uff0cgithub\u9650\u5236\u4e86\u5355\u4e2a\u8d26\u6237\u4e0a\u80fd\u5efa\u7acb\u7684\u79c1\u4eba\u5e93\u7684\u6570\u91cf\uff0c\u6240\u4ee5\u4e00\u4e9b\u9ad8\u9891\u4f7f\u7528\u8005\u53ef\u80fd\u9700\u8981\u901a\u8fc7\u5176\u4ed6\u9014\u5f84\u6765\u5efa\u7acb\u81ea\u5df1\u7684\u4ee3\u7801\u5e93\u3002\u5728\u8fd9\u4e2a\u65f6\u5019\uff0c\u81ea\u5df1\u642d\u5efagithub\u5c31\u6210\u4e3a\u4e86\u4e00\u4e2a\u9009\u62e9\u3002\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5728linux\u7cfb\u7edf\u4e0b\uff0c\u901a\u8fc7gogs\u642d\u5efa\u81ea\u5df1\u7684github\uff0c\u4ee5\u89e3\u653egithub\u8d26\u6237\u7684\u9650\u5236\u3002 \u4e00\u3001\u5b89\u88c5\u73af\u5883 \u5728\u5f00\u59cb\u642d\u5efa\u524d\uff0c\u9700\u8981\u786e\u4fdd\u7cfb\u7edf\u5b89\u88c5\u4e86\u76f8\u5e94\u7684\u73af\u5883\uff1a MySQL or PostgreSQL Go &gt;= 1.12.x Git &gt;= 1.7.1 (2.x recommended) \u5bf9\u4e8eUbuntu\u7cfb\u7edf\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5MySQL\uff1a sudo apt-get update sudo apt-get install mysql-server \u767b\u5f55\u540e\u590d\u5236 Go\u7684\u5b89\u88c5\u65b9\u5f0f\u53ef\u4ee5\u5728\u5b98\u7f51\u4e2d\u4e0b\u8f7d\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u5e76\u6309\u7167\u8bf4\u660e\u8fdb\u884c\u5904\u7406\u3002 \u5bf9\u4e8e\u67d0\u4e9b\u7248\u672c\u7684Ubuntu\u6216Debian\u7cfb\u7edf\uff0c\u53ef\u80fd\u6ca1\u6709\u5b89\u88c5git-core\uff0c\u9700\u8981\u8fdb\u884c\u5b89\u88c5\uff1a sudo apt-get update sudo apt-get install git-core \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u5b89\u88c5Gogs \u4eceGithub\u4e0a\u4e0b\u8f7dGogs\u7684\u6700\u65b0\u7248\u672c\u5e76\u89e3\u538b\u5230\u8be5\u76ee\u5f55\u4e0b\uff1a wget https:\/\/dl.gogs.io\/gogs_latest_linux_amd64.tar.gz tar xvfz gogs_latest_linux_amd64.tar.gz \u767b\u5f55\u540e\u590d\u5236 \u8fdb\u5165\u4e0b\u8f7d\u7684Gogs\u76ee\u5f55\uff0c\u6267\u884c\u5b89\u88c5\uff1a cd gogs .\/gogs install \u767b\u5f55\u540e\u590d\u5236 \u5728\u6267\u884c\u5b89\u88c5\u65f6\u9700\u8981\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a Do you want to install as Windows [&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-18949","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18949","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=18949"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18949\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}