{"id":84384,"date":"2024-03-29T14:45:59","date_gmt":"2024-03-29T06:45:59","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=84384"},"modified":"2024-03-29T14:45:59","modified_gmt":"2024-03-29T06:45:59","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e4%b8%ad%e5%ae%89%e8%a3%85%e5%92%8c%e9%85%8d%e7%bd%aegitea%e8%87%aa%e6%89%98%e7%ae%a1git%e6%9c%8d%e5%8a%a1","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/84384.html","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e2d\u5b89\u88c5\u548c\u914d\u7f6eGitea\u81ea\u6258\u7ba1Git\u670d\u52a1"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/03\/uploading_images2024-03-19_18-49-02_1413.png?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728Linux\u4e2d\u5b89\u88c5\u548c\u914d\u7f6eGitea\u81ea\u6258\u7ba1Git\u670d\u52a1\" \/><\/p>\n<p>Gitea\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u4ee3\u7801\u6258\u7ba1\u89e3\u51b3\u65b9\u6848\uff0c\u57fa\u4e8eGo\u8bed\u8a00\u5f00\u53d1\u3002<strong>\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u3001\u5feb\u901f\u548c\u53ef\u6269\u5c55\u7684Git\u670d\u52a1<\/strong>\uff0c\u662f\u56e2\u961f\u534f\u4f5c\u548c\u7248\u672c\u63a7\u5236\u7684\u7406\u60f3\u9009\u62e9\u3002\u5b89\u88c5\u548c\u914d\u7f6eGitea\u5305\u62ec\u4e86\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a<strong>\u83b7\u53d6Gitea\u7684\u6700\u65b0\u7248\u8f6f\u4ef6\u5305\u3001\u8bbe\u7f6e\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u3001\u5b89\u88c5\u6570\u636e\u5e93\u3001\u5b89\u88c5Gitea\u3001\u4ee5\u53ca\u914d\u7f6eGitea\u7684\u81ea\u542f\u52a8\u548c\u5b89\u5168\u8bbe\u7f6e<\/strong>\u3002\u5728\u63a5\u4e0b\u6765\u7684\u4ecb\u7ecd\u4e2d\uff0c\u6211\u5c06\u4f1a\u8be6\u5c3d\u5730\u89e3\u91ca\u6bcf\u4e00\u4e2a\u6b65\u9aa4\uff0c\u786e\u4fdd\u5373\u4f7f\u662f\u521d\u5b66\u8005\u4e5f\u80fd\u591f\u987a\u5229\u5730\u5728Linux\u73af\u5883\u4e0b\u5b89\u88c5\u548c\u914d\u7f6eGitea\u81ea\u6258\u7ba1Git\u670d\u52a1\u3002<\/p>\n<h2><strong>\u4e00\u3001\u51c6\u5907\u73af\u5883\uff1a<\/strong><\/h2>\n<p>\u5728\u5b89\u88c5Gitea\u4e4b\u524d\uff0c\u5fc5\u987b\u786e\u4fddLinux\u670d\u52a1\u5668\u6ee1\u8db3\u6700\u4f4e\u8981\u6c42\uff0c\u5e76\u5df2\u7ecf\u5b89\u88c5\u4e86\u5fc5\u8981\u7684\u4f9d\u8d56\u3002Gitea\u80fd\u591f\u8fd0\u884c\u5728\u5404\u79cdLinux\u53d1\u884c\u7248\u4e0a\uff0c\u4f8b\u5982Ubuntu\u3001Fedora\u3001Debian\u7b49\u3002<\/p>\n<p>1. \u66f4\u65b0\u7cfb\u7edf\u5305\u5217\u8868\uff1a<\/p>\n<p>\u9996\u5148\uff0c\u767b\u5f55\u5230Linux\u670d\u52a1\u5668\uff0c\u5e76\u901a\u8fc7SSH\u83b7\u53d6\u6743\u9650\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff0c\u786e\u4fdd\u6240\u6709\u7684\u8f6f\u4ef6\u90fd\u662f\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt update<\/p>\n<p>sudo apt upgrade -y<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u5b89\u88c5Git\uff1a<\/p>\n<p>Gitea\u4f5c\u4e3aGit\u670d\u52a1\uff0c\u81ea\u7136\u8981\u6c42\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86Git\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Git\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt install git<\/p>\n<p>&#8220;`<\/p>\n<h2><strong>\u4e8c\u3001\u5b89\u88c5\u6570\u636e\u5e93\uff1a<\/strong><\/h2>\n<p>Gitea\u652f\u6301\u5982MySQL\u3001PostgreSQL\u548cSQLite3\u7b49\u591a\u79cd\u6570\u636e\u5e93\u3002\u8fd9\u91cc\u4ee5PostgreSQL\u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728Linux\u4e0a\u5b89\u88c5\u548c\u914d\u7f6e\u3002<\/p>\n<p>1. \u5b89\u88c5PostgreSQL\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt install postgresql postgresql-contrib<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u521b\u5efa\u7528\u6237\u548c\u6570\u636e\u5e93\uff1a<\/p>\n<p>\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u9700\u8981\u4e3aGitea\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u548c\u7528\u6237\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo -u postgres psql<\/p>\n<p>postgres=# CREATE USER gitea WITH PASSWORD &#8216;giteaPassword&#8217;;<\/p>\n<p>postgres=# CREATE DATABASE giteadb OWNER gitea;<\/p>\n<p>postgres=# \\q<\/p>\n<p>&#8220;`<\/p>\n<h2><strong>\u4e09\u3001\u5b89\u88c5Gitea\uff1a<\/strong><\/h2>\n<p>\u5b89\u88c5\u597d\u6570\u636e\u5e93\u4e4b\u540e\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u5b89\u88c5Gitea\u672c\u8eab\u3002<\/p>\n<p>1. \u83b7\u53d6Gitea\u4e8c\u8fdb\u5236\u6587\u4ef6\uff1a<\/p>\n<p>\u9996\u5148\u9700\u8981\u4e0b\u8f7dGitea\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u53ef\u4ee5\u4eceGitea\u7684\u5b98\u65b9\u7f51\u7ad9\u6216GitHub\u4ed3\u5e93\u4e2d\u83b7\u53d6\u5230\u6700\u65b0\u7248\u672c\u7684\u4e0b\u8f7d\u94fe\u63a5\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528wget\u4e0b\u8f7d\u6700\u65b0\u7248\u672cGitea\u7684\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>wget -O gitea https:\/\/dl.gitea.io\/gitea\/[\u7248\u672c\u53f7]\/gitea-[\u7248\u672c\u53f7]-linux-amd64<\/p>\n<p>&#8220;`<\/p>\n<p>\u8bb0\u5f97\u66ff\u6362[\u7248\u672c\u53f7]\u4e3a\u5b9e\u9645\u7684\u7248\u672c\u53f7\u3002<\/p>\n<p>2. \u5b89\u88c5Gitea\uff1a<\/p>\n<p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u7ed9\u4e8c\u8fdb\u5236\u6587\u4ef6\u8bbe\u7f6e\u6267\u884c\u6743\u9650\uff0c\u5e76\u5c06\u5176\u79fb\u52a8\u5230\u5168\u5c40\u8def\u5f84\u4e0b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>chmod +x gitea<\/p>\n<p>sudo mv gitea \/usr\/local\/bin\/gitea<\/p>\n<p>&#8220;`<\/p>\n<h2><strong>\u56db\u3001\u8bbe\u7f6e\u7cfb\u7edf\u670d\u52a1\uff1a<\/strong><\/h2>\n<p>\u4e3a\u4e86\u80fd\u8ba9Gitea\u6b63\u5e38\u8fd0\u884c\uff0c\u9700\u8981\u5c06\u5176\u8bbe\u7f6e\u4e3a\u7cfb\u7edf\u670d\u52a1\uff0c\u5e76\u914d\u7f6e\u81ea\u542f\u52a8\u3002<\/p>\n<p>1. \u521b\u5efaGitea\u7528\u6237\u548c\u5206\u7ec4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo adduser &#8211;system &#8211;group &#8211;disabled-password &#8211;shell \/bin\/bash &#8211;home \/home\/gitea gitea<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u521b\u5efa\u670d\u52a1\u6587\u4ef6\uff1a<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3agitea.service\u7684\u7cfb\u7edf\u670d\u52a1\u6587\u4ef6\uff0c\u5e76\u5728\/etc\/systemd\/system\/\u76ee\u5f55\u4e0b\u914d\u7f6e\u76f8\u5e94\u7684\u670d\u52a1\u5185\u5bb9\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo nano \/etc\/systemd\/system\/gitea.service<\/p>\n<p>&#8220;`<\/p>\n<p>\u5c06\u4ee5\u4e0b\u914d\u7f6e\u5185\u5bb9\u7c98\u8d34\u8fdb\u53bb\uff08\u8bb0\u5f97\u786e\u8ba4\u8def\u5f84\u548c\u7528\u6237\u914d\u7f6e\u65e0\u8bef\uff09\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>[Unit]<\/p>\n<p>Description=Gitea (Git with a cup of tea)<\/p>\n<p>After=syslog.target<\/p>\n<p>After=network.target<\/p>\n<p>[Service]<\/p>\n<p>RestartSec=2s<\/p>\n<p>Type=simple<\/p>\n<p>User=gitea<\/p>\n<p>Group=gitea<\/p>\n<p>WorkingDirectory=\/var\/lib\/gitea\/<\/p>\n<p>ExecStart=\/usr\/local\/bin\/gitea web -c \/etc\/gitea\/app.ini<\/p>\n<p>Restart=always<\/p>\n<p>Environment=USER=gitea HOME=\/home\/gitea GITEA_WORK_DIR=\/var\/lib\/gitea<\/p>\n<p>[Install]<\/p>\n<p>WantedBy=multi-user.target<\/p>\n<p>&#8220;`<\/p>\n<h2><strong>\u4e94\u3001\u914d\u7f6e\u548c\u542f\u52a8Gitea\uff1a<\/strong><\/h2>\n<p>\u73b0\u5728Gitea\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u914d\u7f6e\u5e76\u542f\u52a8\u5b83\u3002<\/p>\n<p>1. \u542f\u52a8Gitea\u670d\u52a1\uff1a<\/p>\n<p>\u4fdd\u5b58\u5e76\u9000\u51fa\u670d\u52a1\u6587\u4ef6\u540e\uff0c\u542f\u52a8Gitea\u670d\u52a1\uff0c\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo systemctl start gitea<\/p>\n<p>sudo systemctl enable gitea<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u8bbf\u95ee\u5e76\u914d\u7f6eGitea\uff1a<\/p>\n<p>\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668\u7684IP\u5730\u5740\u548c\u914d\u7f6e\u7684\u7aef\u53e3\uff08\u9ed8\u8ba4\u662f3000\uff09\uff0c\u6839\u636e\u754c\u9762\u63d0\u793a\u5b8c\u6210Gitea\u7684\u5b89\u88c5\u8bbe\u7f6e\u3002<\/p>\n<h2><strong>\u516d\u3001\u5b89\u5168\u548c\u7ef4\u62a4\uff1a<\/strong><\/h2>\n<p>\u5728\u786e\u4fddGitea\u6b63\u5e38\u8fd0\u884c\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u9700\u8981\u8fdb\u884c\u5b89\u5168\u8bbe\u7f6e\u548c\u65e5\u5e38\u7ef4\u62a4\u3002<\/p>\n<p>1. \u8bbe\u7f6eNginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\uff08\u53ef\u9009\uff09\uff1a<\/p>\n<p>\u53ef\u4ee5\u5b89\u88c5Nginx\u5e76\u5c06\u5176\u914d\u7f6e\u4e3aGitea\u7684\u53cd\u5411\u4ee3\u7406\uff0c\u8fd9\u6837\u53ef\u4ee5\u4f7f\u752880\u6216443\u7aef\u53e3\uff0c\u5e76\u542f\u7528SSL\/TLS\u52a0\u5bc6\u3002<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt install nginx<\/p>\n<p>sudo nano \/etc\/nginx\/sites-av<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>lable\/gitea<\/p>\n<p>&#8220;`<\/p>\n<p>\u914d\u7f6eNginx\u7ad9\u70b9\u6587\u4ef6\uff0c\u5c06\u8bf7\u6c42\u4ee3\u7406\u81f3Gitea\u3002<\/p>\n<p>2. \u914d\u7f6eSSL\/TLS\u8bc1\u4e66\uff1a<\/p>\n<p>\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u5b89\u5168\uff0c\u5f3a\u70c8\u5efa\u8bae\u914d\u7f6eSSL\/TLS\u8bc1\u4e66\u3002\u4f7f\u7528Let&#8217;s Encrypt\u53ef\u4ee5\u514d\u8d39\u83b7\u53d6\u8bc1\u4e66\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>sudo apt install certbot<\/p>\n<p>sudo certbot &#8211;nginx -d yourdomain.com<\/p>\n<p>&#8220;`<\/p>\n<h2><strong>\u4e03\u3001\u603b\u7ed3\uff1a<\/strong><\/h2>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u4e4b\u540e\uff0c\u60a8\u5c06\u62e5\u6709\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u81ea\u6258\u7ba1Git\u670d\u52a1\u3002Gitea\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\uff0c\u4f46\u662f\u5374\u62e5\u6709\u9ad8\u5ea6\u7684\u53ef\u5b9a\u5236\u6027\u548c\u4e30\u5bcc\u7684\u529f\u80fd\u3002\u901a\u8fc7\u4e25\u5bc6\u7684\u5b89\u5168\u8bbe\u7f6e\u548c\u5b9a\u671f\u7684\u7ef4\u62a4\u66f4\u65b0\uff0c\u60a8\u7684\u4ee3\u7801\u6258\u7ba1\u73af\u5883\u5c06\u4f1a\u7a33\u5b9a\u53ef\u9760\uff0c\u4e3a\u60a8\u7684\u8f6f\u4ef6\u5f00\u53d1\u5de5\u4f5c\u63d0\u4f9b\u5f3a\u6709\u529b\u7684\u652f\u6301\u3002<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5Gitea\uff1f<\/strong><\/p>\n<p>\u8981\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5Gitea\uff0c\u9996\u5148\u9700\u8981\u4e0b\u8f7dGitea\u7684\u6700\u65b0\u7248\u672c\u3002\u7136\u540e\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u89e3\u538b\u4e0b\u8f7d\u7684\u6587\u4ef6\u5e76\u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\u3002\u63a5\u4e0b\u6765\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c`.\/gitea web`\u547d\u4ee4\u542f\u52a8Gitea\uff0c\u7136\u540e\u8bbf\u95ee`http:\/\/localhost:3000`\u6765\u914d\u7f6eGitea\u3002<\/p>\n<p><strong>\u5982\u4f55\u914d\u7f6eGitea\u5b9e\u73b0\u81ea\u6258\u7ba1Git\u670d\u52a1\uff1f<\/strong><\/p>\n<p>\u914d\u7f6eGitea\u5b9e\u73b0\u81ea\u6258\u7ba1Git\u670d\u52a1\u7684\u6b65\u9aa4\u5305\u62ec\u521b\u5efa\u7ba1\u7406\u5458\u8d26\u6237\u3001\u914d\u7f6e\u6570\u636e\u5e93\u3001\u8bbe\u7f6e\u57df\u540d\u548cHTTPS\u4ee5\u53ca\u914d\u7f6e\u90ae\u4ef6\u670d\u52a1\u7b49\u3002\u5728Gitea\u7684Web\u754c\u9762\u4e2d\uff0c\u7ba1\u7406\u5458\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u754c\u9762\u8bbe\u7f6e\u8fd9\u4e9b\u53c2\u6570\uff0c\u5982\u6dfb\u52a0\u65b0\u7528\u6237\uff0c\u914d\u7f6e\u5907\u4efd\u4efb\u52a1\u7b49\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e0a\u66f4\u65b0Gitea\u670d\u52a1\uff1f<\/strong><\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e0a\u66f4\u65b0Gitea\u670d\u52a1\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u9996\u5148\u505c\u6b62\u5f53\u524d\u8fd0\u884c\u7684Gitea\u670d\u52a1\uff0c\u7136\u540e\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Gitea\u538b\u7f29\u5305\u5e76\u89e3\u538b\u3002\u63a5\u7740\uff0c\u5c06\u4e4b\u524d\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5982`app.ini`\uff09\u590d\u5236\u5230\u65b0\u7248\u672c\u4e2d\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8Gitea\u670d\u52a1\u5373\u53ef\u5b8c\u6210\u66f4\u65b0\u3002\u5728\u66f4\u65b0\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u914d\u7f6e\u6587\u4ef6\u7684\u6b63\u786e\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Gitea\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u4ee3\u7801\u6258\u7ba1\u89e3\u51b3\u65b9\u6848\uff0c\u57fa\u4e8eGo\u8bed\u8a00\u5f00\u53d1\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u3001\u5feb\u901f\u548c\u53ef\u6269\u5c55\u7684Git\u670d\u52a1\uff0c\u662f\u56e2\u961f [&hellip;]","protected":false},"author":1,"featured_media":84385,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[384],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/84384"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=84384"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/84384\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/84385"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=84384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=84384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=84384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}