{"id":56,"date":"2022-11-25T06:26:54","date_gmt":"2022-11-25T13:26:54","guid":{"rendered":"https:\/\/optout.eu.org\/?page_id=56"},"modified":"2022-11-25T12:37:40","modified_gmt":"2022-11-25T19:37:40","slug":"install-mastodon-server-from-source","status":"publish","type":"page","link":"https:\/\/blogs.ubc.ca\/fediverse\/mastodon-server-guide\/install-mastodon-server-from-source\/","title":{"rendered":"\u957f\u6bdb\u8c61 Mastodon \u5efa\u7ad9\u6307\u5357 | \u7b2c\u4e94\u7ae0\uff1a\u5b89\u88c5\u957f\u6bdb\u8c61\u670d\u52a1\u5668\uff08\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\uff09"},"content":{"rendered":"<p>\u672c\u7ae0\u8282\u4ec5\u4ecb\u7ecd\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u7684\u65b9\u5f0f\u3002<\/p>\n<h2>\u767b\u5f55\u670d\u52a1\u5668 SSH<\/h2>\n<p>\u5728\u7535\u8111\u4e0a\u5b89\u88c5\u4e00\u4e2a SSH \u5ba2\u6237\u7aef\uff0c\u7528\u4e8e\u767b\u5f55\u670d\u52a1\u5668\u547d\u4ee4\u884c\u3002<\/p>\n<p>\u5e38\u89c1\u7684 SSH \u5ba2\u6237\u7aef\u6709\uff1a<\/p>\n<ul>\n<li>PuTTY<\/li>\n<li>Termius<\/li>\n<li>Bitvise SSH Client<\/li>\n<li>Mac \u81ea\u5e26 Terminal<\/li>\n<li>&#8230;<\/li>\n<\/ul>\n<p>\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 Termius \u4f5c\u4e3a SSH \u5ba2\u6237\u7aef\u3002<\/p>\n<p>Termius \u4e0b\u8f7d\uff1a<\/p>\n<ul>\n<li>MacOS: <a href=\"https:\/\/termius.com\/mac-os\">https:\/\/termius.com\/mac-os<\/a><\/li>\n<li>Windows: <a href=\"https:\/\/termius.com\/windows\">https:\/\/termius.com\/windows<\/a><\/li>\n<\/ul>\n<p>\u5b89\u88c5\u5e76\u6253\u5f00 Termius \u540e\uff0c\u51fa\u73b0\u4ee5\u4e0b\u9875\u9762\uff0c\u53ef\u4ee5\u6ce8\u518c\u4e00\u4e2a Termius \u8d26\u6237\uff0c\u6216\u8005\u70b9\u51fb <code>Continue without account<\/code> \uff08\u4e0b\u56fe\u7ea2\u8272\u7bad\u5934\u5904\uff09\u4e0d\u6ce8\u518c\u8d26\u6237\u76f4\u63a5\u4f7f\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-57\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u6ce8\u518c\u4e00\u4e2a-Termius-\u8d26\u6237-1024x633.png\" alt=\"\" width=\"1024\" height=\"633\" \/><\/p>\n<p>\u70b9\u51fb <code>New Host<\/code> \u6dfb\u52a0\u670d\u52a1\u5668\uff0c\u5728 <code>Address<\/code> \u5904\u586b\u5199\u4f60\u7684\u670d\u52a1\u5668 IP \u5730\u5740\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-58\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u6dfb\u52a0\u670d\u52a1\u5668-1024x510.png\" alt=\"\" width=\"1024\" height=\"510\" \/><\/p>\n<p>\u63a5\u7740\u7ee7\u7eed\u586b\u5199\u670d\u52a1\u5668\u7684\u767b\u5f55\u540d\u3001\u5bc6\u7801\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u521b\u5efa\u670d\u52a1\u5668\u65f6\uff0c\u9009\u62e9\u4e86\u5bc6\u7801\u767b\u5f55\u65b9\u5f0f\uff08\u6ca1\u6709\u751f\u6210\u586b\u5199 SSH Key\uff09\uff0c\u5219\u53ea\u9700\u8981\u586b\u5199\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801\uff08\u4e0b\u56fe 2 \u5904\uff09\uff0c\u4e0d\u9700\u8981\u70b9\u51fb Keys\uff0c\u76f4\u63a5\u70b9\u51fb\u53f3\u4e0a\u89d2 Save \u4fdd\u5b58\u5373\u53ef\u3002<\/li>\n<li>\u5982\u679c\u521b\u5efa\u670d\u52a1\u5668\u65f6\uff0c\u751f\u6210\u5e76\u586b\u5199\u4e86 SSH Key \u5219\u4e0d\u8981\u586b\u5199\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801\uff0c\u800c\u662f\u70b9\u51fb <code>Keys -&gt;<\/code> \u6dfb\u52a0\u767b\u5f55\u79c1\u94a5\uff08\u4e0b\u56fe 3 \u5904\uff09\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-59\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u6dfb\u52a0\u767b\u5f55\u79c1\u94a5-1024x510.png\" alt=\"\" width=\"1024\" height=\"510\" \/><\/p>\n<p>\u70b9\u51fb <code>Keys<\/code> \u540e\uff0c\u5728 <code>Private Key<\/code> \u4e00\u680f\u586b\u5199\u521b\u5efa\u670d\u52a1\u5668\u65f6\u751f\u6210\u7684\u79c1\u94a5\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2 Save \u4fdd\u5b58\uff1a<\/p>\n<p><em>\uff08\u5bc6\u7801\u767b\u5f55\u65b9\u5f0f\u8bf7\u5ffd\u7565\u6b64\u6b65\u9aa4\uff09<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-60\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u586b\u5199\u521b\u5efa\u670d\u52a1\u5668\u65f6\u751f\u6210\u7684\u79c1\u94a5-1024x633.png\" alt=\"\" width=\"1024\" height=\"633\" \/><\/p>\n<p>\u4fdd\u5b58\u540e\uff0c\u53cc\u51fb\u767b\u5f55\u670d\u52a1\u5668 SSH\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-61\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u767b\u5f55\u670d\u52a1\u5668-SSH-1024x633.png\" alt=\"\" width=\"1024\" height=\"633\" \/><\/p>\n<p>\u51fa\u73b0\u5982\u4e0b\u63d0\u793a\uff0c\u70b9\u51fb <code>YES<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-62\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u51fa\u73b0\u5982\u4e0b\u63d0\u793a\uff0c\u70b9\u51fb-YES-1024x633.png\" alt=\"\" width=\"1024\" height=\"633\" \/><\/p>\n<p>\u51fa\u73b0\u4ee5\u4e0b\u9875\u9762\uff0c\u4ee3\u8868 SSH \u767b\u5f55\u6210\u529f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-63\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u51fa\u73b0\u4ee5\u4e0b\u9875\u9762\uff0c\u4ee3\u8868-SSH-\u767b\u5f55\u6210\u529f-1024x633.png\" alt=\"\" width=\"1024\" height=\"633\" \/><\/p>\n<h2>\u5b89\u88c5\u957f\u6bdb\u8c61\u670d\u52a1<\/h2>\n<p>**\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u5c06\u5728 <a href=\"https:\/\/docs.joinmastodon.org\/zh-cn\/admin\/install\/\">\u957f\u6bdb\u8c61\u5b98\u65b9\u5b89\u88c5\u6307\u5357<\/a> \u7684\u57fa\u7840\u4e0a\uff0c\u9644\u4e0a\u989d\u5916\u8bf4\u660e\uff0c\u8fdb\u884c\u8be6\u89e3\u3002**\u5efa\u8bae\u9605\u8bfb\u672c\u6587\u7684\u540c\u65f6\uff0c\u5bf9\u7167\u5b98\u65b9\u6559\u7a0b\u7684\u82f1\u6587\u9875\u9762 <a href=\"https:\/\/docs.joinmastodon.org\/admin\/install\/\">Installing from source<\/a> \u9605\u8bfb\uff0c\u4ee5\u514d\u7531\u4e8e\u7248\u672c\u5347\u7ea7\uff0c\u800c\u6559\u7a0b\u6216 Mastodon \u5b98\u7f51\u7ffb\u8bd1\u672a\u66f4\u65b0\u5bfc\u81f4\u7684\u5b89\u88c5\u914d\u7f6e\u9519\u8bef\u3002<\/p>\n<p>\u672c\u6559\u7a0b\u4ee5 Ubuntu 18.04 \u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4f8b\u3002<\/p>\n<p>\u5982\u679c\u4f60\u4e0d\u662f\u4ee5 <code>root<\/code> \u7528\u6237\u767b\u5f55 SSH\uff0c\u8bf7\u5148\u5207\u6362\u5230 root\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo -i\n<\/code><\/pre>\n<p>\u8bf7 <strong>\u9010\u884c\u590d\u5236<\/strong> \u4ee3\u7801\u6846\u5185\u7684\u547d\u4ee4\uff0c\u7c98\u8d34\u5230 Termius \u4e2d\uff0c\u7136\u540e\u6309\u56de\u8f66\u6267\u884c\u6bcf\u4e00\u6761\u547d\u4ee4\u3002<\/p>\n<h3>\u6dfb\u52a0\u865a\u62df\u5185\u5b58\uff08SWAP\uff09<\/h3>\n<p>\u4e3a\u4e86\u4fdd\u8bc1\u5b89\u88c5\u65f6\u4e0d\u5d29\u6e83\uff0c\u670d\u52a1\u5668\u7a33\u5b9a\u8fd0\u884c\uff0c\u9700\u8981\u6dfb\u52a0\u865a\u62df\u5185\u5b58\uff0c\u53ef\u4ee5\u6839\u636e <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-add-swap-space-on-ubuntu-18-04\">\u8fd9\u7bc7\u6559\u7a0b<\/a> \u624b\u52a8\u6dfb\u52a0\u865a\u62df\u5185\u5b58\u3002<\/p>\n<h3><strong>\u66f4\u65b0\u7cfb\u7edf<\/strong><\/h3>\n<pre><code class=\"language-bash\">apt update &amp;&amp; apt upgrade -y\n<\/code><\/pre>\n<h3><strong>\u8f6f\u4ef6\u4ed3\u5e93<\/strong><\/h3>\n<h3><strong>Node.js<\/strong><\/h3>\n<pre><code class=\"language-bash\">curl -sL &lt;https:\/\/deb.nodesource.com\/setup_12.x&gt; | bash -\n<\/code><\/pre>\n<h3><strong>Yarn<\/strong><\/h3>\n<pre><code class=\"language-bash\">curl -sS &lt;https:\/\/dl.yarnpkg.com\/debian\/pubkey.gpg&gt; | apt-key add -\n*echo* \"deb &lt;https:\/\/dl.yarnpkg.com\/debian\/&gt; stable main\" | tee \/etc\/apt\/sources.list.d\/yarn.list\n<\/code><\/pre>\n<h3><strong>\u8f6f\u4ef6\u5305<\/strong><\/h3>\n<pre><code class=\"language-bash\">apt update\n<\/code><\/pre>\n<pre><code class=\"language-bash\">apt install -y \\\\\n  imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \\\\\n  g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \\\\\n  bison build-essential libssl-dev libyaml-dev libreadline6-dev \\\\\n  zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev \\\\\n  nginx redis-server redis-tools postgresql postgresql-contrib \\\\\n  certbot python-certbot-nginx yarn libidn11-dev libicu-dev libjemalloc-dev\n<\/code><\/pre>\n<h3><strong>\u5b89\u88c5 Ruby<\/strong><\/h3>\n<p>\u56e0\u4e3a\u4f7f\u7528 rbenv \u53ef\u4ee5\u66f4\u5bb9\u6613\u7684\u83b7\u5f97\u6b63\u786e\u7684\u7248\u672c\u5e76\u5728\u65b0\u7248\u672c\u53d1\u5e03\u540e\u8fdb\u884c\u66f4\u65b0\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 rbenv \u6765\u7ba1\u7406Ruby\u7248\u672c\u3002rbenv \u5fc5\u987b\u5b89\u88c5\u5728\u5355\u4e2aLinux\u7528\u6237\u4e2d\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2aMastodon\u7528\u6237\uff1a<\/p>\n<pre><code class=\"language-bash\">adduser --disabled-login mastodon\n<\/code><\/pre>\n<p>\u51fa\u73b0\u8be5\u63d0\u793a\u65f6\uff0c\u4e00\u8def\u56de\u8f66\u5373\u53ef\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-64\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u51fa\u73b0\u8be5\u63d0\u793a\u65f6\uff0c\u4e00\u8def\u56de\u8f66\u5373\u53ef.png\" alt=\"\" width=\"860\" height=\"241\" \/><\/p>\n<p>\u5207\u6362\u5230mastodon\u7528\u6237\uff1a<\/p>\n<pre><code class=\"language-bash\">su - mastodon\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-65\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u5207\u6362\u5230mastodon\u7528\u6237-1024x83.png\" alt=\"\" width=\"1024\" height=\"83\" \/><\/p>\n<p>\u5207\u6362\u5230 mastodon \u7528\u6237\u540e\uff0c\u547d\u4ee4\u884c\u6700\u5f00\u5934\uff08@\u524d\u9762\uff09\u7684\u7528\u6237\u540d\u4ece <code>root<\/code>\u53d8\u4e3a\u4e86 <code>mastodon<\/code>\uff0c\u4ee3\u8868\u4f60\u6b63\u4ee5 <code>mastodon<\/code> \u7528\u6237\u7684\u8eab\u4efd\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<p>\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\u5b89\u88c5 rbenv \u548c rbenv-build\uff1a<\/p>\n<pre><code class=\"language-bash\">git clone &lt;https:\/\/github.com\/rbenv\/rbenv.git&gt; ~\/.rbenv\n*cd* ~\/.rbenv &amp;&amp; src\/configure &amp;&amp; make -C src\n*echo* 'export PATH=\"$HOME\/.rbenv\/bin:$PATH\"' &gt;&gt; ~\/.bashrc\n*echo* 'eval \"$(rbenv init -)\"' &gt;&gt; ~\/.bashrc\n*exec* bash\ngit clone &lt;https:\/\/github.com\/rbenv\/ruby-build.git&gt; ~\/.rbenv\/plugins\/ruby-build\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u64cd\u4f5c\u5b8c\u6210\uff0c\u6211\u4eec\u4fbf\u53ef\u4ee5\u5b89\u88c5\u6b63\u786e\u7684 Ruby \u7248\u672c\uff1a<\/p>\n<p>\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>\u8fd9\u4e2a\u6b65\u9aa4\u4f1a\u8017\u8d39\u8f83\u957f\u65f6\u95f4\uff0c\u901f\u5ea6\u53d6\u51b3\u4e8e\u670d\u52a1\u5668\u914d\u7f6e\u3002\u5982\u679c\u4e2d\u9014\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u670d\u52a1\u5668\u5185\u5b58\u4e0d\u591f\uff0c\u6216\u8005\u6ca1\u6709\u914d\u7f6e\u865a\u62df\u5185\u5b58\u3002<\/li>\n<li>\u672c\u6559\u7a0b\u4ee5 Ruby v2.7.2 \u4e3a\u4f8b\u5b89\u88c5 Mastodon v3.3.0\u3002\u8bf7\u53c2\u8003 Mastodon \u7684 <a href=\"https:\/\/github.com\/tootsuite\/mastodon\/releases\">Releases<\/a> \u9875\u9762\u68c0\u67e5\u6700\u65b0\u7248\u672c Mastodon \u662f\u5426\u5efa\u8bae\u66f4\u9ad8\u7684 Ruby \u7248\u672c\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">*RUBY_CONFIGURE_OPTS*=--with-jemalloc rbenv install 2.7.2\n<\/code><\/pre>\n<pre><code class=\"language-bash\">rbenv global 2.7.2\n<\/code><\/pre>\n<pre><code class=\"language-bash\">gem install bundler --no-document\n<\/code><\/pre>\n<p>\u8fd4\u56deroot\u7528\u6237\uff1a<\/p>\n<pre><code class=\"language-bash\">*exit*\n<\/code><\/pre>\n<h2><strong>\u914d\u7f6e\u957f\u6bdb\u8c61\u670d\u52a1<\/strong><\/h2>\n<h3><strong>\u914d\u7f6e PostgreSQL<\/strong><\/h3>\n<h3><strong>\u6027\u80fd\u8c03\u4f18\uff08\u53ef\u9009\uff09<\/strong><\/h3>\n<p>\u4e3a\u4e86\u4f18\u5316\u6027\u80fd\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u00a0<a href=\"https:\/\/pgtune.leopard.in.ua\/#\/\">pgTune<\/a>\u00a0\u751f\u6210\u4e00\u4e2a\u5408\u9002\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u4f8b\u5982\uff0c2GB \u5185\u5b58\u7684 VPS \u670d\u52a1\u5668\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-66\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/2GB-\u5185\u5b58\u7684-VPS-\u670d\u52a1\u5668-1024x710.png\" alt=\"\" width=\"1024\" height=\"710\" \/><\/p>\n<p>\u5f97\u5230\uff1a<\/p>\n<pre><code class=\"language-bash\"># DB Version: 10\n# OS Type: linux\n# DB Type: web\n# Total Memory (RAM): 2 GB\n# CPUs num: 1\n# Data Storage: ssd\n\nmax_connections = 200\nshared_buffers = 512MB\neffective_cache_size = 1536MB\nmaintenance_work_mem = 128MB\ncheckpoint_completion_target = 0.7\nwal_buffers = 16MB\ndefault_statistics_target = 100\nrandom_page_cost = 1.1\neffective_io_concurrency = 200\nwork_mem = 1310kB\nmin_wal_size = 1GB\nmax_wal_size = 4GB\n<\/code><\/pre>\n<p>\u7f16\u8f91\u00a0<code>\/etc\/postgresql\/10\/main\/postgresql.conf<\/code>\u00a0\u4e2d\u7684\u76f8\u5e94\u6570\u503c\uff1a<\/p>\n<pre><code class=\"language-bash\">nano \/etc\/postgresql\/10\/main\/postgresql.conf\n<\/code><\/pre>\n<p>\u66ff\u6362 <code>max_connections = 200<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-67\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u66ff\u6362-max_connections-200-1024x474.png\" alt=\"\" width=\"1024\" height=\"474\" \/><\/p>\n<p>\u66ff\u6362 <code>shared_buffers = 512MB<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-68\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u66ff\u6362-shared_buffers-512MB-1024x278.png\" alt=\"\" width=\"1024\" height=\"278\" \/><\/p>\n<p>\u5728\u672b\u5c3e\u52a0\u4e0a\u5269\u4f59\u7684\u914d\u7f6e\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-69\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u52a0\u4e0a\u5269\u4f59\u7684\u914d\u7f6e-1024x572.png\" alt=\"\" width=\"1024\" height=\"572\" \/><\/p>\n<p>\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u4f7f\u7528 ctrl + X \u9000\u51fa\uff0c\u6309 Y \u3001\u56de\u8f66\u4fdd\u5b58\u3002<\/p>\n<p>\u5e76\u4f7f\u7528\u00a0<code>systemctl restart postgresql<\/code>\u00a0\u547d\u4ee4\u91cd\u542f PostgreSQL\u3002<\/p>\n<pre><code class=\"language-bash\">systemctl restart postgresql\n<\/code><\/pre>\n<h3><strong>\u521b\u5efa\u5e10\u6237<\/strong><\/h3>\n<p>\u4f60\u9700\u521b\u5efa\u4e00\u4e2a\u4f9bMastodon\u4f7f\u7528\u7684PostgreSQL\u5e10\u6237\u3002\u521b\u5efa\u4e00\u4e2a\u4f7f\u7528\u201cident\u201d\u8ba4\u8bc1\u65b9\u5f0f\u7684\u5e10\u6237\u662f\u6700\u5bb9\u6613\u7684\u914d\u7f6e\u65b9\u6cd5\uff0c\u5373PostgreSQL\u5e10\u6237\u4e0d\u9700\u8981\u72ec\u7acb\u7684\u5bc6\u7801\u5e76\u7531\u540c\u540dLinux\u7528\u6237\u4f7f\u7528\u3002<\/p>\n<p>\u6253\u5f00\u63a7\u5236\u53f0\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo -u postgres psql\n<\/code><\/pre>\n<p>\u5728\u63a7\u5236\u53f0\u4e2d\u6267\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">CREATE USER mastodon CREATEDB;\n<\/code><\/pre>\n<pre><code class=\"language-bash\">\\\\q\n<\/code><\/pre>\n<p>\u5b8c\u6210\uff01<\/p>\n<h3><strong>\u914d\u7f6e Mastodon<\/strong><\/h3>\n<p>\u73b0\u5728\u8be5\u4e0b\u8f7dMastodon\u4ee3\u7801\u4e86\u3002\u5207\u6362\u81f3mastodon\u7528\u6237\uff1a<\/p>\n<pre><code class=\"language-bash\">su - mastodon\n<\/code><\/pre>\n<h3><strong>\u68c0\u51fa\u4ee3\u7801<\/strong><\/h3>\n<p>\u4f7f\u7528git\u4e0b\u8f7d\u6700\u65b0\u7a33\u5b9a\u7248Mastodon\uff1a<\/p>\n<pre><code class=\"language-bash\">git clone &lt;https:\/\/github.com\/tootsuite\/mastodon.git&gt; live &amp;&amp; *cd* live\ngit checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)\n<\/code><\/pre>\n<h3><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong><\/h3>\n<p>\u73b0\u5728\uff0c\u5b89\u88c5Ruby\u548cJavaScript\u4f9d\u8d56\uff1a<\/p>\n<pre><code class=\"language-bash\">bundle config deployment 'true'\nbundle config without 'development test'\nbundle install -j$(getconf _NPROCESSORS_ONLN)\nyarn install --pure-lockfile\n<\/code><\/pre>\n<p>\u4e24\u4e2a<code>bundle config<\/code>\u547d\u4ee4\u4ec5\u4ec5\u7b2c\u4e00\u6b21\u5b89\u88c5\u4f9d\u8d56\u65f6\u9700\u8981\u3002\u5982\u679c\u4f60\u4e4b\u540e\u8fdb\u884c\u5347\u7ea7\u6216\u91cd\u5b89\u88c5\u4f9d\u8d56\uff0c\u53ea\u9700\u8981<code>bundle install<\/code>\u5c31\u591f\u4e86\u3002<\/p>\n<h3><strong>\u751f\u6210\u914d\u7f6e\u6587\u4ef6<\/strong><\/h3>\n<p>\u8fd0\u884c\u4ea4\u4e92\u5f0f\u5b89\u88c5\u5411\u5bfc\uff1a<\/p>\n<pre><code class=\"language-bash\">*RAILS_ENV*=production bundle *exec* rake mastodon:setup\n<\/code><\/pre>\n<p>\u5b83\u5c06\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u9884\u7f16\u8bd1\u9759\u6001\u6587\u4ef6<\/li>\n<li>\u521b\u5efa\u6570\u636e\u5e93schema<\/li>\n<\/ul>\n<p>\u914d\u7f6e\u6587\u4ef6\u88ab\u4fdd\u5b58\u5728<code>.env.production<\/code>\u3002\u5982\u679c\u4f60\u613f\u610f\u7684\u8bdd\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u5e76\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u3002\u8bf7\u53c2\u9605<a href=\"https:\/\/docs.joinmastodon.org\/zh-cn\/admin\/config\/\">\u914d\u7f6e\u6587\u4ef6\u7684\u6587\u6863<\/a>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-70\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u914d\u7f6e\u6587\u4ef61-1024x374.png\" alt=\"\" width=\"1024\" height=\"374\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-71\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u914d\u7f6e\u6587\u4ef62-1024x127.png\" alt=\"\" width=\"1024\" height=\"127\" \/><\/p>\n<p>\u4ee5 SendGrid \u4e3a\u4f8b\uff0cSendGrid \u7684 SMTP \u4fe1\u606f\u4e3a\uff1a<\/p>\n<p>SMTP \u670d\u52a1\u5668\u5730\u5740\uff1a<a href=\"http:\/\/smtp.sendgrid.net\">smtp.sendgrid.net<\/a><\/p>\n<p>SMTP \u7aef\u53e3\u53f7\uff1a465\uff08SSL\uff09\u6216 2525<\/p>\n<p>SMTP \u7528\u6237\u540d\uff1aapikey<\/p>\n<p>SMTP \u5bc6\u7801\uff1a\u5728\u4e4b\u524d\u7684\u6b65\u9aa4\u4e2d\u83b7\u5f97\u7684\u4e00\u957f\u4e32 API Key<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-72\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-1024x162.png\" alt=\"\" width=\"1024\" height=\"162\" srcset=\"https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-1024x162.png 1024w, https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-300x48.png 300w, https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-768x122.png 768w, https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-1536x243.png 1536w, https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1-624x99.png 624w, https:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid1.png 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-73\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/SendGrid2-1024x284.png\" alt=\"\" width=\"1024\" height=\"284\" \/><\/p>\n<p>\u4f60\u5df2\u7ecf\u5b8c\u6210\u9700\u4f7f\u7528mastodon\u7528\u6237\u8fdb\u884c\u7684\u64cd\u4f5c\uff0c\u8bf7\u5207\u6362\u56deroot\u7528\u6237\uff1a<\/p>\n<pre><code class=\"language-bash\">exit\n<\/code><\/pre>\n<h3>\u66f4\u6539\u9ed8\u8ba4\u8bed\u8a00\u4e3a\u4e2d\u6587<\/h3>\n<p>Mastodon \u9ed8\u8ba4\u4e3a\u82f1\u6587\u754c\u9762\uff0c\u5982\u9700\u6539\u4e3a\u4e2d\u6587\uff0c\u53ef\u4ee5\u7f16\u8f91 <code>.env.production<\/code> \u6587\u4ef6\uff1a<\/p>\n<pre><code class=\"language-bash\">nano \/home\/mastodon\/live\/.env.production\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u4e00\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">DEFAULT_LOCALE=zh-CN\n<\/code><\/pre>\n<p>\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u4f7f\u7528 ctrl + X \u9000\u51fa\uff0c\u6309 Y \u3001\u56de\u8f66\u4fdd\u5b58\u3002<\/p>\n<h3><strong>\u914d\u7f6e nginx<\/strong><\/h3>\n<p>\u4eceMastodon\u76ee\u5f55\u590d\u5236\u914d\u7f6e\u6587\u4ef6\u6a21\u7248\u5230nginx\uff1a<\/p>\n<pre><code class=\"language-bash\">cp \/home\/mastodon\/live\/dist\/nginx.conf \/etc\/nginx\/sites-available\/mastodon\nln -s \/etc\/nginx\/sites-available\/mastodon \/etc\/nginx\/sites-enabled\/mastodon\n<\/code><\/pre>\n<p>\u7f16\u8f91\u00a0<code>\/etc\/nginx\/sites-available\/mastodon<\/code>\uff0c\u66ff\u6362\u00a0<code>example.com<\/code>\u00a0\u4e3a\u4f60\u81ea\u5df1\u7684\u57df\u540d\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u505a\u51fa\u5176\u5b83\u7684\u4e00\u4e9b\u8c03\u6574\u3002<\/p>\n<pre><code class=\"language-bash\">nano \/etc\/nginx\/sites-available\/mastodon\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-74\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/mastodon-nginx-1024x514.png\" alt=\"\" width=\"1024\" height=\"514\" \/><\/p>\n<p>\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u4f7f\u7528 ctrl + X \u9000\u51fa\uff0c\u6309 Y \u3001\u56de\u8f66\u4fdd\u5b58\u3002<\/p>\n<p>\u91cd\u8f7d nginx \u4ee5\u4f7f\u53d8\u66f4\u751f\u6548\uff1a<\/p>\n<pre><code class=\"language-bash\">service nginx reload\n<\/code><\/pre>\n<h3><strong>\u83b7\u53d6SSL\u8bc1\u4e66<\/strong><\/h3>\n<p>\u6211\u4eec\u5c06\u4f7f\u7528 Let\u2019s Encrypt \u83b7\u53d6\u4e00\u4e2a\u514d\u8d39\u7684SSL\u8bc1\u4e66\u3002<\/p>\n<p>\u66ff\u6362\u00a0<code>example.com<\/code>\u00a0\u4e3a\u4f60\u81ea\u5df1\u7684\u57df\u540d\uff1a<\/p>\n<pre><code class=\"language-bash\">certbot --nginx -d example.com\n<\/code><\/pre>\n<p>\u73b0\u5728\u4f60\u5e94\u8be5\u80fd\u591f\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u4f60\u7684\u57df\u540d\uff0c\u7136\u540e\u770b\u5230\u4e00\u53ea\u5927\u8c61\u9524\u51fb\u7535\u8111\u5c4f\u5e55\u7684\u9519\u8bef\u9875\u9762\u3002\u8fd9\u662f\u56e0\u4e3a\u6211\u4eec\u8fd8\u6ca1\u6709\u542f\u52a8Mastodon\u8fdb\u7a0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-75\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u83b7\u53d6\u8bc1\u4e66-1024x468.png\" alt=\"\" width=\"1024\" height=\"468\" \/><\/p>\n<p>\u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u6539\u7528 webroot \u65b9\u5f0f\u83b7\u53d6\u8bc1\u4e66\u3002\u66ff\u6362\u00a0<code>example.com<\/code>\u00a0\u4e3a\u4f60\u81ea\u5df1\u7684\u57df\u540d\uff0c\u66ff\u6362\u00a0<code>admin@example.com<\/code>\u00a0\u4e3a\u4f60\u81ea\u5df1\u7684\u90ae\u7bb1\uff1a<\/p>\n<pre><code class=\"language-bash\">certbot certonly --webroot --webroot-path \/home\/mastodon\/live\/public\/ --renew-by-default --email admin@example.com --text --agree-tos -d example.com\n<\/code><\/pre>\n<p>\u5982\u7b7e\u53d1\u6210\u529f\uff0c\u4f1a\u51fa\u73b0\u5982\u4e0b\u63d0\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-76\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u5982\u7b7e\u53d1\u6210\u529f\uff0c\u4f1a\u51fa\u73b0\u5982\u4e0b\u63d0\u793a-1024x532.png\" alt=\"\" width=\"1024\" height=\"532\" \/><\/p>\n<h3><strong>\u914d\u7f6e systemd \u670d\u52a1<\/strong><\/h3>\n<p>\u4eceMastodon\u76ee\u5f55\u590d\u5236systemd\u670d\u52a1\u6a21\u7248\uff1a<\/p>\n<pre><code class=\"language-bash\">cp \/home\/mastodon\/live\/dist\/mastodon-*.service \/etc\/systemd\/system\/\n<\/code><\/pre>\n<p>\u6700\u540e\uff0c\u542f\u52a8\u65b0systemd\u670d\u52a1\u5e76\u5c06\u8be5\u670d\u52a1\u8bbe\u4e3a\u5f00\u673a\u81ea\u52a8\u6fc0\u6d3b\uff1a<\/p>\n<pre><code class=\"language-bash\">systemctl daemon-reload\nsystemctl start mastodon-web mastodon-sidekiq mastodon-streaming\nsystemctl *enable* mastodon-web mastodon-sidekiq mastodon-streaming\n<\/code><\/pre>\n<p>\u5b83\u4eec\u5c06\u5728\u5f00\u673a\u542f\u52a8\u65f6\u81ea\u52a8\u5f00\u59cb\u8fd0\u884c\u3002<\/p>\n<p><strong>\u6b22\u547c\u5427\uff01\u4f60\u73b0\u5728\u53ef\u4ee5\u4ece\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u4f60\u7684\u57df\u540d\u4e86\uff01<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-77\" src=\"http:\/\/blogs.ubc.ca\/fediverse\/files\/2022\/11\/\u4f60\u73b0\u5728\u53ef\u4ee5\u4ece\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u4f60\u7684\u57df\u540d\u4e86-1024x760.png\" alt=\"\" width=\"1024\" height=\"760\" \/><\/p>\n<p>\u672c\u7ae0\u8282\u5b8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7ae0\u8282\u4ec5\u4ecb\u7ecd\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u7684\u65b9\u5f0f\u3002 \u767b\u5f55\u670d\u52a1\u5668 SSH \u5728\u7535\u8111\u4e0a\u5b89\u88c5\u4e00\u4e2a SSH \u5ba2\u6237\u7aef\uff0c\u7528\u4e8e\u767b\u5f55\u670d\u52a1\u5668\u547d\u4ee4\u884c\u3002 \u5e38\u89c1\u7684 SSH \u5ba2\u6237\u7aef\u6709\uff1a PuTTY Termius Bitvise SSH Client Mac \u81ea\u5e26 Terminal &#8230; \u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 Termius \u4f5c\u4e3a SSH \u5ba2\u6237\u7aef\u3002 Termius \u4e0b\u8f7d\uff1a MacOS: https:\/\/termius.com\/mac-os Windows: https:\/\/termius.com\/windows \u5b89\u88c5\u5e76\u6253\u5f00 Termius \u540e\uff0c\u51fa\u73b0\u4ee5\u4e0b\u9875\u9762\uff0c\u53ef\u4ee5\u6ce8\u518c\u4e00\u4e2a Termius \u8d26\u6237\uff0c\u6216\u8005\u70b9\u51fb Continue without account \uff08\u4e0b\u56fe\u7ea2\u8272\u7bad\u5934\u5904\uff09\u4e0d\u6ce8\u518c\u8d26\u6237\u76f4\u63a5\u4f7f\u7528\u3002 \u70b9\u51fb New Host \u6dfb\u52a0\u670d\u52a1\u5668\uff0c\u5728 Address \u5904\u586b\u5199\u4f60\u7684\u670d\u52a1\u5668 IP \u5730\u5740\u3002 \u63a5\u7740\u7ee7\u7eed\u586b\u5199\u670d\u52a1\u5668\u7684\u767b\u5f55\u540d\u3001\u5bc6\u7801\u3002 \u5982\u679c\u521b\u5efa\u670d\u52a1\u5668\u65f6\uff0c\u9009\u62e9\u4e86\u5bc6\u7801\u767b\u5f55\u65b9\u5f0f\uff08\u6ca1\u6709\u751f\u6210\u586b\u5199 SSH Key\uff09\uff0c\u5219\u53ea\u9700\u8981\u586b\u5199\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801\uff08\u4e0b\u56fe 2 \u5904\uff09\uff0c\u4e0d\u9700\u8981\u70b9\u51fb Keys\uff0c\u76f4\u63a5\u70b9\u51fb\u53f3\u4e0a\u89d2 Save \u4fdd\u5b58\u5373\u53ef\u3002 [&hellip;]<\/p>\n","protected":false},"author":40229,"featured_media":0,"parent":8,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template-full-width.php","meta":{"footnotes":""},"class_list":["post-56","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/pages\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/users\/40229"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":1,"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/pages\/56\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/pages\/56\/revisions\/191"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/pages\/8"}],"wp:attachment":[{"href":"https:\/\/blogs.ubc.ca\/fediverse\/wp-json\/wp\/v2\/media?parent=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}