{"id":673,"date":"2019-06-05T13:59:23","date_gmt":"2019-06-05T05:59:23","guid":{"rendered":"http:\/\/cn.hostease.com\/blog\/?p=673"},"modified":"2019-06-05T13:59:23","modified_gmt":"2019-06-05T05:59:23","slug":"%e4%bd%bf%e7%94%a8gogs%e5%9c%a8vps%e4%b8%8a%e6%89%98%e7%ae%a1%e8%87%aa%e5%b7%b1%e7%9a%84git%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/blog\/server\/%e4%bd%bf%e7%94%a8gogs%e5%9c%a8vps%e4%b8%8a%e6%89%98%e7%ae%a1%e8%87%aa%e5%b7%b1%e7%9a%84git%e6%9c%8d%e5%8a%a1%e5%99%a8\/","title":{"rendered":"\u4f7f\u7528Gogs\u5728VPS\u4e0a\u6258\u7ba1\u81ea\u5df1\u7684Git\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u4ece\u6700\u521d\u4f5c\u4e3a\u4e00\u4e2a\u8f85\u52a9\u9879\u76ee\u5230\u4e3a\u4efb\u4f55\u5728Linux\u5185\u6838\u4e0a\u5de5\u4f5c\u7684\u56e2\u961f\u63d0\u4f9b\u7248\u672c\u63a7\u5236\u548c\u6e90\u4ee3\u7801\u7ba1\u7406\u7cfb\u7edf\uff0cGit\u5df2\u7ecf\u6210\u4e3a\u8fd1\u5e74\u6765\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e4b\u4e00\u3002\u521b\u5efaGit<a href=\"http:\/\/cn.hostease.com\" target=\"_blank\" rel=\"noopener\"><strong>\u670d\u52a1\u5668<\/strong><\/a>\u7684\u4e00\u4e2a\u4fbf\u5229\u7279\u6027\u662f\uff0c\u591a\u4e2a\u7528\u6237\u80fd\u591f\u5904\u7406\u76f8\u540c\u7684\u6587\u4ef6\uff0c\u901a\u8fc7\u670d\u52a1\u5668\u4e0a\u7684Git\u540c\u6b65\u6570\u636e\uff0c\u4ee5\u4fbf\u534f\u540c\u5de5\u4f5c\u3002\u867d\u7136\u6700\u5e38\u89c1\u7684\u7528\u9014\u662f\u5f00\u53d1\u4eba\u5458\u76f4\u63a5\u5904\u7406\u6e90\u4ee3\u7801\uff0cGit\u8fd8\u7528\u4e8e\u5904\u7406\u4e66\u7c4d\u3001\u8bba\u6587\u3001\u7814\u7a76\u751a\u81f3\u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\u3002Github\u4e3a\u4f7f\u7528Git\u8ddf\u8e2a\u7684\u9879\u76ee\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f88\u597d\u7684\u670d\u52a1\uff0c\u53ef\u4ee5\u5c06\u5176\u7528\u4f5c\u670d\u52a1\u5668\u3002\u4e0d\u5e78\u7684\u662f\uff0c\u5b83\u53ea\u5bf9\u516c\u5171\u6216\u5f00\u6e90\u9879\u76ee\u514d\u8d39\u3002\u5982\u679c\u60f3\u505a\u4e00\u4e2a\u79c1\u4eba\u9879\u76ee\uff0c\u90a3\u4e48\u5c06\u9700\u8981\u4e3a\u6bcf\u4e2a\u7528\u6237\u652f\u4ed8\u670d\u52a1\u8d39\u7528\u3002Git\u662f\u5f00\u6e90\u7684\uff0c\u6240\u4ee5\u6709\u5404\u79cd\u5de5\u5177\u5141\u8bb8\u8fd0\u884c\u81ea\u5df1\u7684\u670d\u52a1\u5668\u3002\u672c\u6587Hostease\u7f8e\u56fd\u670d\u52a1\u5668\u5546\u5c06\u7814\u7a76\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u4f7f\u7528Gogs\u8fdb\u884c\u534f\u4f5c\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u7c7b\u4f3c\u4e8eGithub\u7684\u63a5\u53e3\u3002<\/p>\n<p>Gogs\u9700\u8981\u624b\u52a8\u4e0b\u8f7d\u5e76\u624b\u52a8\u5b89\u88c5\u5230VPS\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u53ef\u4ee5\u5728<strong>\u670d\u52a1\u5668<\/strong>\u4e0a\u914d\u7f6e\u4ee5\u83b7\u53d6\u5305\u5e76\u4fdd\u6301\u6700\u65b0\u7684\u5b58\u50a8\u5e93\u3002\u672c\u4f8b\u5c06\u5728Ubuntu 16.04 VPS\u4e0a\u8fdb\u884c\u914d\u7f6e\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u4e3aDebian\u3001Ubuntu\u6216CentOS\u9009\u62e9\u4e00\u4e2a\u7248\u672c\u3002\u5047\u8bbe\u4f7f\u7528\u7684VPS\u4e13\u95e8\u7528\u4e8e\u4f7f\u7528Gogs\uff0c\u5982\u679c\u8ba1\u5212\u5728\u76f8\u540c\u7684VPS\u4e0a\u8fd0\u884c\u53e6\u4e00\u4e2a\u7f51\u7ad9\uff0c\u5219\u9700\u8981\u76f8\u5e94\u5730\u8c03\u6574\u914d\u7f6e\u3002<\/p>\n<p>wget -qO- https:\/\/dl.packager.io\/srv\/pkgr\/gogs\/key | sudo apt-key add \u2013<\/p>\n<p>sudo wget -O \/etc\/apt\/sources.list.d\/gogs.list \\<\/p>\n<p>https:\/\/dl.packager.io\/srv\/pkgr\/gogs\/pkgr\/installer\/ubuntu\/16.04.repo<\/p>\n<p>sudo apt-get update<\/p>\n<p>sudo apt-get install gogs<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u9700\u8981\u4e3aGogs\u5efa\u7acbMySQL\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u5c06\u4f7f\u7528Nginx\u7f51\u7edc\u6d4f\u89c8\u5668\u6765\u4e3a\u7f51\u9875\u63d0\u4f9b\u670d\u52a1\u3002\u9996\u5148\uff0c\u8bbe\u7f6e\u4e00\u4e9b\u53d8\u91cf\u4ee5\u7b80\u5316\u8bbe\u7f6e\uff1a<\/p>\n<p>APP_NAME = \u201cgogs\u201d<\/p>\n<p>MySQL_PASSWORD = \u201cstrongpass\u201d<\/p>\n<p>GOGS_PASSWORD = \u201canotherpass\u201d<\/p>\n<p>HOSTNAME = \u201cexample.com\u201c<\/p>\n<p>\u5728\u8bbe\u7f6e\u53d8\u91cf\u65f6\uff0c\u9700\u8981\u5c06\u201cstrongpass\u201d\u548c\u201canotherpass\u201d\u66f4\u6539\u4e3a\u5f3a\u5bc6\u7801\uff0c\u5206\u522b\u7528\u4e8e\u6839MySQL\u7528\u6237\u548cgogs MySQL\u7528\u6237\u7684\u5f3a\u5bc6\u7801\u3002\u53e6\u5916\uff0c\u5c06\u201cexample.com\u201d\u66f4\u6539\u4e3a\u6307\u5411<strong>\u670d\u52a1\u5668<\/strong>\u7684\u57df\u540d\uff0c\u7136\u540e\u662f\u9884\u5148\u914d\u7f6eMySQL\u5bc6\u7801\uff1a<\/p>\n<p>sudo debconf-set-selections \u300a\u300a\u300a MySQL-server MySQL-server\/root_password password ${MySQL_PASSWORD}<\/p>\n<p>sudo debconf-set-selections \u300a\u300a\u300a MySQL-server MySQL-server\/root_password_again password ${MySQL_PASSWORD}<\/p>\n<p>\u5b8c\u6210\u4e4b\u540e\uff0c\u5b89\u88c5MySQL\u670d\u52a1\u5668\uff1a<\/p>\n<p>sudo apt-get install MySQL-server<\/p>\n<p>\u73b0\u5728\u521b\u5efa\u4e00\u4e2aGogs\u6570\u636e\u5e93\uff1a<\/p>\n<p>MySQL -uroot -p${MySQL_PASSWORD} -e \u201ccreate database if not exists ${APP_NAME}; create user \u2018${APP_NAME}\u2019@\u2019localhost\u2019 identified by \u2018${GOGS_PASSWORD}; grant all privileges on ${APP_NAME}.* to \u2018${APP_NAME}\u2019@\u2019localhost\u2019;\u201d<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5b89\u88c5Nginx\u865a\u62df<strong>\u670d\u52a1\u5668<\/strong>\uff0c\u4e3a\u8fd9\u4e9b\u6587\u4ef6\u63d0\u4f9b\u670d\u52a1\uff1a\uff08\u8fd9\u91cc\u6709\u670b\u53cb\u53ef\u80fd\u4f1a\u95eeNginx\u4e0eApache\u662f\u4e0d\u662f\u4e00\u6837\u5b89\u88c5\uff0c\u8fd9\u65b9\u9762\u5185\u5bb9\u53ef\u4ee5\u53c2\u8003\u4e86\u89e3\u4e00\u4e0b <a href=\"https:\/\/cn.hostease.com\/blog\/server\/512.html\">Nginx\u4e0eApache\u670d\u52a1\u5668\u5177\u4f53\u6709\u54ea\u4e9b\u533a\u522b<\/a>\u3002<\/p>\n<p>sudo apt-get install nginx<\/p>\n<p>\u7136\u540e\u8bbe\u7f6e\u7f51\u7ad9\u7684\u914d\u7f6e\uff1a<\/p>\n<p>sudo sh -c \u2018echo \u201cserver {<\/p>\n<p>listen 80;<\/p>\n<p>server_name ${HOSTNAME};<\/p>\n<p>location \/ {<\/p>\n<p>proxy_pass http:\/\/localhost:6000;<\/p>\n<p>}<\/p>\n<p>}\u201d \u300b \/etc\/nginx\/sites-available\/default\u2019<\/p>\n<p>\u5b8c\u6210\u540e\uff0c\u91cd\u542fnginx\uff0c\u52a0\u8f7d\u65b0\u914d\u7f6e\uff1a<\/p>\n<p>sudo systemctl restart nginx<\/p>\n<p>\u73b0\u5728\uff0c\u53ef\u4ee5\u5728\u7f51\u7edc\u6d4f\u89c8\u5668\u4e2d\u5bfc\u822a\u5230\u6307\u5411VPS\u7684\u57df\u540d\u6216\u5176IP\u5730\u5740\u6765\u8fde\u63a5\u5230VPS\u3002\u7136\u540e\uff0c\u4f1a\u6536\u5230\u4e00\u4e2a\u7f51\u9875\u95ee\u5019\uff0c\u8be2\u95ee\u7cfb\u7edf\u7684\u914d\u7f6e\u4fe1\u606f\u3002\u5728\u6b64\uff0c\u9700\u8981\u5c06MySQL\u7528\u6237\u66f4\u6539\u4e3a\u201cgogs\u201d\uff0c\u5e76\u5c06\u5bc6\u7801\u8bbe\u7f6e\u4e3a\u4e4b\u524d\u7528\u4e8eGOGS_PASSWORD\u8bbe\u7f6e\u7684\u5bc6\u7801\u3002\u5176\u4f59\u7684\u521d\u59cb\u8bbe\u7f6e\u5e94\u8be5\u662f\u6b63\u5e38\u7684\u3002\u5982\u679c\u5411\u4e0b\u6eda\u52a8\u9875\u9762\u5e76\u5c55\u5f00\u201c\u670d\u52a1\u5668\u548c\u5176\u4ed6\u670d\u52a1\u8bbe\u7f6e\u201d\u90e8\u5206\uff0c\u5efa\u8bae\u5355\u51fb\u4ee5\u7981\u7528\u81ea\u52a8\u6ce8\u518c\uff0c\u5982\u679c\u8ba1\u5212\u4f7f\u7528Gogs\u8fdb\u884c\u79c1\u4eba\u6570\u636e\u7ba1\u7406\uff0c\u5219\u9700\u8981\u7528\u6237\u767b\u5f55\u3002\u7136\u540e\u5728\u5e95\u90e8\u90e8\u5206\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7ba1\u7406\u7528\u6237\u3002\u7136\u540e\u5355\u51fb\u201c\u5b89\u88c5Gogs\u201d\u6309\u94ae\u3002<\/p>\n<p>\u51e0\u79d2\u949f\u540e\uff0c\u9875\u9762\u5c06\u52a0\u8f7d\u65b0\u7684Gogs\u5b89\u88c5\uff0c\u4e3a\u7528\u6237\u6dfb\u52a0\u4e00\u4e9b\u5b58\u50a8\u5e93\u5e76\u4e3a\u5f00\u59cb\u5de5\u4f5c\u505a\u597d\u51c6\u5907\u3002\u4ee5\u4e0a\u5c31\u662fHostease<a href=\"https:\/\/cn.hostease.com\/dedicated-servers.html\">\u7f8e\u56fd\u670d\u52a1\u5668<\/a>\u5546\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u7684Gogs\u5728VPS\u4e0a\u5982\u4f55\u6258\u7ba1\u81ea\u5df1\u7684Git\u670d\u52a1\u5668\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u6700\u521d\u4f5c\u4e3a\u4e00\u4e2a\u8f85\u52a9\u9879\u76ee\u5230\u4e3a\u4efb\u4f55\u5728Linux\u5185\u6838\u4e0a\u5de5\u4f5c\u7684\u56e2\u961f\u63d0\u4f9b\u7248\u672c\u63a7\u5236\u548c\u6e90\u4ee3\u7801\u7ba1\u7406\u7cfb\u7edf\uff0cGit\u5df2\u7ecf\u6210\u4e3a\u8fd1\u5e74\u6765\u6700 &#8230; <a title=\"\u4f7f\u7528Gogs\u5728VPS\u4e0a\u6258\u7ba1\u81ea\u5df1\u7684Git\u670d\u52a1\u5668\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/blog\/server\/%e4%bd%bf%e7%94%a8gogs%e5%9c%a8vps%e4%b8%8a%e6%89%98%e7%ae%a1%e8%87%aa%e5%b7%b1%e7%9a%84git%e6%9c%8d%e5%8a%a1%e5%99%a8\/\" aria-label=\"\u9605\u8bfb \u4f7f\u7528Gogs\u5728VPS\u4e0a\u6258\u7ba1\u81ea\u5df1\u7684Git\u670d\u52a1\u5668\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[31],"class_list":["post-673","post","type-post","status-publish","format-standard","hentry","category-server","tag-31"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/comments?post=673"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/673\/revisions"}],"predecessor-version":[{"id":674,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/673\/revisions\/674"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media?parent=673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/categories?post=673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/tags?post=673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}