hexo/posts/9597b72.html

596 lines
26 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-CN">
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="/img/logo.png">
<meta name="author" content="浪子">
<meta name="subtitle" content="一个分享自己生活的博客">
<meta name="description" content="曾梦想仗剑走天涯;因太胖放弃原计划.">
<meta name="keywords" content=",DIY,黑苹果,分享,自由">
<link rel="alternate" href="/atom.xml " title="提剑追梦" type="application/atom+xml">
<title>在fly.io部署Gotosocial | 提剑追梦</title>
<link rel="stylesheet" href="/css/style.css" >
<link rel="stylesheet" href="/css/partial/dark.css" >
<link rel="stylesheet" href="/css/partial/highlight/atom-one-light.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.sgcd.net/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/a2396837/CDN@latest/css/iconfont.css">
<script src="/js/todark.js"></script>
<meta name="generator" content="Hexo 6.3.0"></head>
</html>
<div class="nav index" style="height: 60px;">
<div class="title animated fadeInDown">
<div class="layui-container">
<div class="nav-title"><a href="/" title="提剑追梦">提剑追梦</a></div>
<div class="nav-list">
<button> <span class=""></span><span style="display: block;"></span><span class=""></span> </button>
<ul class="layui-nav" lay-filter="">
<li class="layui-nav-item">
<a href="/search/ ">
<i class=" fas fa-search-plus " style="color: rgb(3 169 244);"></i>
<span class="layui-nav-item-name">搜索</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/ ">
<i class=" fab fa-fort-awesome " style="color: rgb(255 107 107);"></i>
<span class="layui-nav-item-name">首页</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/archives/ ">
<i class=" fas fa-archive " style="color: rgb(10 189 227);"></i>
<span class="layui-nav-item-name">归档</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/tags/ ">
<i class=" fas fa-hashtag " style="color: rgb(254 202 87);"></i>
<span class="layui-nav-item-name">标签</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/fcircle/ ">
<i class=" fas fa-heart " style="color: rgb(29 209 161);"></i>
<span class="layui-nav-item-name">朋友圈</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/links/ ">
<i class=" fab fa-weixin " style="color: hsl(152deg 73% 45%);"></i>
<span class="layui-nav-item-name">友链</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/memos/ ">
<i class=" fas fa-coffee " style="color:#31c7c1;"></i>
<span class="layui-nav-item-name">说说</span>
</a>
</li>
<li class="layui-nav-item">
<a href="/about/ ">
<i class=" fab fa-grav " style="color: rgb(154 106 247);"></i>
<span class="layui-nav-item-name">关于</span>
</a>
</li>
<li class="layui-nav-item" id="btn-toggle-dark">🌙</li>
<span class="layui-nav-bar" style="left: 342px; top: 78px; width: 0px; opacity: 0;"></span>
</ul>
</div>
</div>
</div>
</div>
<header class="header">
<div class="logo">
<a href="/"><img src="https://img.imsun.org/avatar.jpg" onerror=this.onerror=null,this.src="/img/loading.gif"></a>
</div>
</div>
<div class="motto">
<span>曾梦想仗剑走天涯</span>
</div>
<div class="social">
<a class="social-icon" href="https://github.com/jkjoy" target="_blank" title="Github">
<i class="iconfont icon-GitHub" aria-hidden="true"></i>
</a>
<a class="social-icon" href="mailto:jkjoy@163.com" target="_blank" title="Email">
<i class="iconfont icon-email" aria-hidden="true"></i>
</a>
<a class="social-icon" href="/atom.xml" target="_blank" title="rss">
<i class="iconfont icon-rss" aria-hidden="true"></i>
</a>
</div>
</header>
<article id="post">
<div class="post-title">在fly.io部署Gotosocial</div>
<div class="post-meta">
<div class="post-meta-item date">
<span title="发表于 2023.08.17"><i class="far fa-calendar-alt"></i> 2023.08.17</span>
</div>
<div class="post-meta-item updated">
<span title="更新于 2024.05.09"><i class="far fa-calendar-check"></i> 2024.05.09</span>
</div>
<div class="post-meta-item categories">
<i class="fas fa-inbox article-meta__icon"></i> <a href="/categories/%E5%88%86%E4%BA%AB/">分享</a>
</div>
<div class="post-meta-item wordcount">
<i class="fas fa-pencil-alt"></i> <span class="post-count">552 字</span>
<i class="far fa-clock"></i> <span class="post-count">2 分钟</span>
</div>
</div>
<div class="content">
<blockquote><h3>自动摘要</h3>
ai: 这篇文章介绍了如何使用GoToSocial搭建一个轻量级的社交网络平台。文章首先说明了GoToSocial的特点随后详细描述了在Fly.io和Cloudflare上注册并配置所需服务的步骤。之后提供了在不同操作系统中安装FLYCTL的指导并展示了如何登录、创建应用、设置存储卷以及编辑配置文件。最后文章还涵盖了部署应用、创建用户和管理员账号的过程并给出了演示链接和数据库下载的方法。
</blockquote>
<div><h2 id="关于Gotosocial"><a href="#关于Gotosocial" class="headerlink" title="关于Gotosocial"></a>关于Gotosocial</h2><p>GoToSocial 是一个十分轻量(轻量到甚至没有用户界面,需要使用第三方程序登录、兼容 Mastodon 应用进行使用)的 ActivityPub 联邦社交网络程序,自建 GoToSocial 可以避免您的信息因为所在实例倒闭、不可抗力等原因化为乌有。</p>
<h2 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h2><ul>
<li>注册 Fly.io 账号,并绑卡(避免滥用);</li>
<li>注册 Cloudflare 并启用 R2启用 R2 需要绑卡。新建一个储存桶并创建一个 API 令牌。</li>
</ul>
<h2 id="安装-flyctl"><a href="#安装-flyctl" class="headerlink" title="安装 flyctl"></a>安装 flyctl</h2><ul>
<li>Linux</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -L https://fly.io/install.sh | sh</span><br></pre></td></tr></table></figure>
<ul>
<li>macOS</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -L https://fly.io/install.sh | sh</span><br></pre></td></tr></table></figure>
<ul>
<li>Windows需要开启 RemoteSigned: 管理员运行</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">powershell -Command &quot;iwr https://fly.io/install.ps1 -useb | iex&quot;</span><br></pre></td></tr></table></figure>
<h2 id="登录"><a href="#登录" class="headerlink" title="登录"></a>登录</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">flyctl auth login</span><br><span class="line"></span><br><span class="line"># 若登录失败使用</span><br><span class="line"># flyctl auth login -i </span><br><span class="line"># 输入账号密码进行登录</span><br></pre></td></tr></table></figure>
<h2 id="创建APP"><a href="#创建APP" class="headerlink" title="创建APP"></a>创建APP</h2><p><code>YOURAPPNAME</code>更改为自己希望设置的名称</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flyctl launch --name YOURAPPNAME --image=superseriousbusiness/gotosocial:latest --region hkg --no-deploy</span><br></pre></td></tr></table></figure>
<h2 id="创建储存卷"><a href="#创建储存卷" class="headerlink" title="创建储存卷"></a>创建储存卷</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flyctl volumes create social_data --region hkg --size 1</span><br></pre></td></tr></table></figure>
<h2 id="编辑配置"><a href="#编辑配置" class="headerlink" title="编辑配置"></a>编辑配置</h2><p>编辑根目录下的 <code>fly.toml</code> 配置文件,参考下方</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">app = &quot;gotos&quot; ## 自定义名称</span><br><span class="line">primary_region = &quot;hkg&quot; ##服务器节点,当前为香港</span><br><span class="line"></span><br><span class="line">[experimental]</span><br><span class="line"> vm = true</span><br><span class="line"></span><br><span class="line">[build]</span><br><span class="line"> image = &quot;superseriousbusiness/gotosocial:latest&quot;</span><br><span class="line"></span><br><span class="line">[env]</span><br><span class="line"> GTS_DB_ADDRESS = &quot;/gotosocial/storage/sqlite.db&quot;</span><br><span class="line"> GTS_DB_TLS_MODE = &quot;enable&quot;</span><br><span class="line"> GTS_DB_TYPE = &quot;sqlite&quot;</span><br><span class="line"> GTS_HOST = &quot;GTS的域名&quot;</span><br><span class="line"> GTS_LETSENCRYPT_ENABLED = &quot;false&quot;</span><br><span class="line"> GTS_STORAGE_BACKEND = &quot;s3&quot;</span><br><span class="line"> GTS_STORAGE_S3_BUCKET = &quot;BUCKET名称&quot;</span><br><span class="line"> GTS_STORAGE_S3_ENDPOINT = &quot;#S3 API&quot;</span><br><span class="line"> GTS_STORAGE_S3_ACCESS_KEY = &quot;#api-tokens&quot;</span><br><span class="line"> GTS_STORAGE_S3_SECRET_KEY = &quot;#api-tokens&quot;</span><br><span class="line"> GTS_STORAGE_S3_PROXY = &quot;true&quot;</span><br><span class="line"> # 添加时区为UTC+8</span><br><span class="line"> TZ = &quot;Asia/Chongqing&quot;</span><br><span class="line"></span><br><span class="line">[[mounts]]</span><br><span class="line"> source = &quot;social_data&quot;</span><br><span class="line"> destination = &quot;/gotosocial/storage&quot;</span><br><span class="line"></span><br><span class="line">[http_service]</span><br><span class="line"> internal_port = 8080</span><br><span class="line"> force_https = true</span><br><span class="line"> auto_stop_machines = false</span><br><span class="line"> auto_start_machines = true</span><br><span class="line"> min_machines_running = 1</span><br><span class="line"> processes = [&quot;app&quot;]</span><br></pre></td></tr></table></figure>
<p>以上配置中<code>GTS_STORAGE_S3_ENDPOINT</code>不需要带<code>https:</code>和最后的<code>/BUCKET名称</code></p>
<h2 id="部署"><a href="#部署" class="headerlink" title="部署"></a>部署</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flyctl deploy</span><br></pre></td></tr></table></figure>
<p>启动成功后会显示一个URL,能成功访问则代表部署成功。</p>
<h2 id="创建用户和管理员"><a href="#创建用户和管理员" class="headerlink" title="创建用户和管理员"></a>创建用户和管理员</h2><p><code>fly.toml </code>文件目录执行</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flyctl ssh console</span><br></pre></td></tr></table></figure>
<ul>
<li>创建用户</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/gotosocial/gotosocial admin account create --username YOUR_USERNAME --email YOUR@EMAIL.COM --password &#x27;SOME_VERY_GOOD_PASSWD&#x27;</span><br></pre></td></tr></table></figure>
<p><code>YOUR_USERNAME</code>为用户名<br><code>YOUR@EMAIL.COM</code>为邮箱<br><code>SOME_VERY_GOOD_PASSWD</code>为密码,需设置足够复杂,太简单会提示密码不够安全,需重新设置</p>
<ul>
<li>设置管理员</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/gotosocial/gotosocial admin account promote --username YOUR_USERNAME</span><br></pre></td></tr></table></figure>
<h2 id="演示"><a href="#演示" class="headerlink" title="演示"></a>演示</h2><p><a target="_blank" rel="noopener" href="https://m.ima.cm/">https://m.ima.cm</a></p>
<p><a target="_blank" rel="noopener" href="https://m.ima.cm/@jkjoy">https://m.ima.cm/@jkjoy</a></p>
<h2 id="下载数据库"><a href="#下载数据库" class="headerlink" title="下载数据库"></a>下载数据库</h2><p><code>fly.toml </code>文件目录执行</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flyctl sftp get /gotosocial/storage/sqlite.db</span><br></pre></td></tr></table></figure>
</div>
<div class="post-copyright">
<div class="copyright-item">
<span> 作者: 浪子</span>
</div>
<div class="copyright-item">
<span> 链接: <a href="https://blog.jkjoy.cn/posts/9597b72.html">https://blog.jkjoy.cn/posts/9597b72.html</a></span>
</div>
<div class="copyright-item">
<span> 声明: 本博客所有文章除特别声明外,均采用许可协议 <a target="_blank" rel="noopener" href="http://creativecommons.org/licenses/by-nc/4.0/">CC-BY-NC-4.0</a> 转载请注明出处!</span>
</div>
</div>
</div>
<div class="share-reward">
<div class="share">
<div class="social-share" data-sites="wechat,weibo,qq"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css">
<script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js"></script>
</div>
<div class="reward">
<div style="padding: 10px 0; margin-left: 20px; width: 90%; text-align: center;">
<div class="reward-content">
<ul id="donateBox" class="list pos-a">
<li id="PayPal"><a href="https://paypal.me/jkjoy" target="_blank" title="贝宝">贝宝</a></li>
<li id="AliPay" title="支付宝"><img data-img="https://blogcdn.loliko.cn/ali.png" onerror=this.onerror=null,this.src="/img/loading.gif"></img></li>
<li id="WeChat" title="微信"><img date-img="https://blogcdn.loliko.cn/wx.png" onerror=this.onerror=null,this.src="/img/loading.gif"></img></li>
</ul>
<div id="QRBox" class="pos-f left-100">
<div id="MainBox"></div>
</div>
</div>
</div>
</div>
</div>
<div class="post_tags">
<i class="fas fa-tag"></i> <a href="/tags/Gotosocial/" class="tag">Gotosocial</a>
<i class="fas fa-tag"></i> <a href="/tags/fly-io/" class="tag">fly.io</a>
<i class="fas fa-tag"></i> <a href="/tags/%E9%83%A8%E7%BD%B2/" class="tag">部署</a>
</div>
<div class="post-nav">
<div class="post-nav-prev post-nav-item">
<a href="/posts/8084c141.html" >如何在Fly.io部署typecho<i class="fa fa-chevron-left"></i></a>
</div>
<div class="post-nav-next post-nav-item">
<a href="/posts/c80a64e9.html" >在fly.io部署artalk评论系统<i class="fa fa-chevron-right"></i></a>
</div>
</div>
<h3><i class="far fa-comment"></i> 评论</h3>
<div id="tcomment"></div>
<script src="https://cdn.staticfile.org/twikoo/1.6.32/twikoo.all.min.js"></script>
<script>
twikoo.init({
envId: 'https://t.jkjoy.cn',
el: '#tcomment',
})
</script>
</article>
<a id="gotop" href="javascript:" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
<div id="bottom-outer">
<div id="bottom-inner">
© 2020 <i class="fa fa-heart" id="heart"></i> 浪子
<br>
Powered by
<a target="_blank" rel="noopener" href="http://hexo.io">hexo</a> | Theme is <a target="_blank" rel="noopener" href="https://github.com/a2396837/hexo-theme-blank/">blank</a>
<div class="icp-info">
<a href="" target="_blank"> </a>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/layui-src@2.5.5/dist/layui.min.js"></script>
<script src="/js/script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script>
<script>
window.lazyLoadOptions = {
elements_selector: 'img',
threshold: 0
}
</script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script>
<script>
var images = $('img').not('.nav-logo img').not('.card img').not($('a>img')).not('.reward-content img')
images.each(function (i, o) {
var lazyloadSrc = $(o).attr('data-src') ? $(o).attr('data-src') : $(o).attr('src')
$(o).wrap(`<a href="${lazyloadSrc}" data-fancybox="group" data-caption="${$(o).attr('alt')}" class="fancybox"></a>`)
})
</script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script>
<script>
$().fancybox({
selector: '[data-fancybox]',
loop: true,
transitionEffect: 'slide',
protect: true,
buttons: ['slideShow', 'fullScreen', 'thumbs', 'close']
})
</script>
<script>
jQuery(document).ready(function () {
var QRBox = $('#QRBox');
var MainBox = $('#MainBox');
var AliPayQR = 'https://blogcdn.loliko.cn/ali.png';
var WeChanQR = 'https://blogcdn.loliko.cn/wx.png';
function showQR(QR) {
if (QR) {
MainBox.css('background-image', 'url(' + QR + ')');
}
$('#donateBox').addClass('blur');
QRBox.fadeIn(300, function (argument) {
MainBox.addClass('showQR');
});
}
$('#donateBox>li').click(function (event) {
var thisID = $(this).attr('id');
if (thisID === 'AliPay') {
showQR(AliPayQR);
} else if (thisID === 'WeChat') {
showQR(WeChanQR);
}
});
MainBox.click(function (event) {
MainBox.removeClass('showQR').addClass('hideQR');
setTimeout(function (a) {
QRBox.fadeOut(300, function (argument) {
MainBox.removeClass('hideQR');
});
$('#DonateText,#donateBox,#github').removeClass('blur');
}, 600);
});
});
</script>
<div id="QPlayer">
<div id="pContent">
<div id="player">
<span class="cover"></span>
<div class="ctrl">
<div class="musicTag marquee">
<strong>Title</strong>
<span> - </span>
<span class="artist">Artist</span>
</div>
<div class="progress">
<div class="timer left">0:00</div>
<div class="contr">
<div class="rewind icon"></div>
<div class="playback icon"></div>
<div class="fastforward icon"></div>
</div>
<div class="right">
<div class="liebiao icon"></div>
</div>
</div>
</div>
</div>
<div class="ssBtn">
<div class="adf"><i class="fas fa-music" style="color: #Fff;"></i></div>
</div>
</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/a2396837/CDN@latest/css/audio.css">
<ol id="playlist"></ol>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery.marquee@1.5.0/jquery.marquee.min.js"></script>
<script>
var playlist = [];
playlist.push({title:'我要开花',artist:'二手玫瑰',mp3:'https://xy07-1251893119.cos.ap-beijing-1.myqcloud.com/%E4%BA%8C%E6%89%8B%E7%8E%AB%E7%91%B0%20-%20%E6%88%91%E8%A6%81%E5%BC%80%E8%8A%B1.mp3',cover:'https://p1.music.126.net/DSTg1dR7yKsyGq4IK3NL8A==/109951163046050093.jpg'})
var isRotate = true;
var autoplay = false;
</script>
<script src="https://cdn.jsdelivr.net/gh/a2396837/CDN@latest/js/player.js"></script>
<script>
function bgChange(){
var lis= $('.lib');
for(var i=0; i<lis.length; i+=2)
lis[i].style.background = 'rgba(246, 246, 246, 0.5)';
}
window.onload = bgChange;
</script>
<script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js"></script>
<script>
!function (e, t, a) {
var initCopyCode = function(){
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
copyHtml += ' <i class="fa fa-clipboard"></i><span>复制</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
}
initCopyCode();
}(window, document);
</script>
<script>
var btntop = $('#gotop');
btntop.on('click', function (e) {
e.preventDefault();
$('html, body').animate({ scrollTop: 0 }, '300');
});
var $table = $('.content table').not($('figure.highlight > table'))
$table.each(function () {
$(this).wrap('<div class="table-wrap"></div>')
})
</script>
</html>