{"id":6063,"date":"2016-09-28T16:25:40","date_gmt":"2016-09-28T08:25:40","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6063"},"modified":"2016-09-28T16:28:31","modified_gmt":"2016-09-28T08:28:31","slug":"%e5%9c%a8ubuntu%e4%b8%8a%e9%9d%a2%e7%94%a8gogs%e6%90%ad%e5%bb%bagit%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6063.html","title":{"rendered":"\u5728ubuntu\u4e0a\u9762\u7528gogs\u642d\u5efagit\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u5047\u8bbe\u6211\u4eec\u4ee5deploy\u7528\u6237\u90e8\u7f72\uff0cgit\u7528\u6237\u5b58\u653egit\u4ed3\u5e93\u3002gogs\u7a0b\u5e8f\u653e\u5728deploy\u7528\u6237home\u76ee\u5f55\u4e0b\u9762\u3002<\/p>\n<p>\u521b\u5efa\u7528\u6237deploy<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo useradd -m -s \/bin\/bash deploy\r\nsudo passwd deploy\r\nsudo usermod -aG sudo deploy\r\n<\/pre>\n<p>\u521b\u5efa\u7528\u6237git<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo useradd -m -s \/bin\/bash git\r\n<\/pre>\n<p>\u6ce8\u610fgit\u7528\u6237\u4e00\u5b9a\u8981\u6709 shell \uff0c\u4e5f\u5c31\u662f -m \/bin\/bash\uff0c\u5426\u5219\u540e\u671f\u4f1a\u51fa\u73b0\u62a5\u9519\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nCloning into 'xxx'...\r\nfatal: Could not read from remote repository.\r\n\r\nPlease make sure you have the correct access rights\r\nand the repository exists.\r\n<\/pre>\n<p>\u4ece\u5b98\u7f51\u4e0b\u8f7dgogs\u4e8c\u8fdb\u5236\u5b89\u88c5\u5305<\/p>\n<p>\u4e0b\u8f7d\u9875\u9762\uff1ahttps:\/\/gogs.io\/docs\/installation\/install_from_binary<\/p>\n<p>\u89e3\u538b\u5230\u76ee\u5f55 \/home\/deploy\/gogs\/<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nls \/home\/deploy\/gogs\/\r\ncustom  data  gogs  LICENSE  log  public  README.md  README_ZH.md  scripts  templates\r\n<\/pre>\n<p>\u5b89\u88c5superviosr\u6765\u8fd0\u884c gogs<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install supervisor \r\ncp -r \/etc\/supervisor \/home\/deploy\/etc\/supervisor\r\nsudo rm -r \/etc\/supervisor\r\nsudo ln -s \/home\/deploy\/etc\/supervisor \/etc\/supervisor\r\nvim \/home\/deploy\/etc\/supervisor\/supervisord.conf\r\n<\/pre>\n<p>unix_http_server\u8282\u70b9\u6dfb\u52a0\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nchown=deploy:deploy\r\n<\/pre>\n<p>\u4fee\u6539supervisord\u8282\u70b9\u7684\u65e5\u5fd7\u76ee\u5f55\uff0c\u5230 \/home\/deploy\/log \u4e0b\u9762\u3002<\/p>\n<p>\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6 vim ~\/etc\/supervisor\/conf.d\/gogs.conf \uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;program:gogs]\r\ncommand=\/home\/deploy\/gogs\/gogs web\r\nautorestart=true\r\nuser=git\r\nredirect_stderr = true\r\ndirectory = \/home\/deploy\/gogs\/\r\nenvironment = HOME=&quot;\/home\/git&quot;, USER=&quot;git&quot;\r\nstdout_logfile = \/home\/deploy\/log\/supervisor\/gogs.log\r\n<\/pre>\n<p>\u7136\u540e\u542f\u52a8supervisor\u3002<\/p>\n<p>\u518d\u914d\u7f6e nginx \u4e2d\u8f6c\uff0cvim ~\/etc\/nginx\/upstreams.conf<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nupstream gogs{\r\n    server 127.0.0.1:3000;\r\n}\r\n<\/pre>\n<p>vim ~\/etc\/nginx\/sites-enabled\/gogs.conf<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nserver {\r\n        listen 80;\r\n\r\n        server_name git.xxx.com;\r\n        access_log  \/var\/log\/nginx\/git-access.log;\r\n        error_log  \/var\/log\/nginx\/git-error.log;\r\n\r\n        root \/home\/deploy\/gogs\/;\r\n        client_max_body_size 10m;\r\n\r\n        location ^~ \/ {\r\n                proxy_set_header Host $http_host;\r\n                proxy_set_header X-Real-IP $remote_addr;\r\n                proxy_set_header X-Scheme $scheme;\r\n                proxy_pass http:\/\/gogs;\r\n                proxy_next_upstream error;\r\n        }\r\n}\r\n<\/pre>\n<p>gogs\u7684\u90e8\u5206\u914d\u7f6e\uff0c \/home\/deploy\/gogs\/custom\/conf\/app.ini<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;repository]\r\nROOT = \/home\/git\/gogs-repositories\r\n\r\n&#x5B;server]\r\nDOMAIN       = git.xxx.com\r\nHTTP_PORT    = 3000\r\nROOT_URL     = http:\/\/git.xxx.com\/\r\nDISABLE_SSH  = false\r\nSSH_PORT     = 22\r\nOFFLINE_MODE = false\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5047\u8bbe\u6211\u4eec\u4ee5deploy\u7528\u6237\u90e8\u7f72\uff0cgit\u7528\u6237\u5b58\u653egit\u4ed3\u5e93\u3002gogs\u7a0b\u5e8f\u653e\u5728deploy\u7528\u6237home\u76ee\u5f55\u4e0b\u9762\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6063","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6063"}],"version-history":[{"count":3,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6063\/revisions"}],"predecessor-version":[{"id":6066,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6063\/revisions\/6066"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}