• Github每日精选(第12期):去中心化的社交平台mastodon


    mastodon

    Mastodon 是一个基于 ActivityPub 的免费开源社交网络服务器,用户可以在其中关注朋友并发现新朋友。在 Mastodon 上,用户可以发布他们想要的任何内容:链接、图片、文本、视频。所有 Mastodon 服务器都可以作为联合网络进行互操作(一台服务器上的用户可以与另一台服务器上的用户无缝通信,包括实现 ActivityPub 的非`Mastodon 软件)!

    mastodon的github地址在这里
    在这里插入图片描述

    也许一段视频以后,你会更懂得,他是什么东西。

    【社交网络】什么是Mastodon?(中文字幕)

    安装mastodon

    需要的条件
    • 一台运行Ubuntu 20.04或Debian 11且您具有 root 访问权限的机器
    • Mastodon 服务器的域名(或子域),例如example.com
    • 电子邮件递送服务或其他SMTP 服务器

    您将以 root 身份运行这些命令。如果您还不是 root,请切换到 root:

    数据库

    确保首先安装 curl、wget、gnupg、apt-transport-https、lsb-release 和 ca-certificates:

    apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates
    
    • 1
    node.js
    curl -sL https://deb.nodesource.com/setup_16.x | bash -
    
    • 1
    PostgreSQL
    wget -O /usr/share/keyrings/postgresql.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc
    echo "deb [signed-by=/usr/share/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/postgresql.list
    
    • 1
    • 2

    为了获得最佳性能,您可以使用pgTune生成适当的配置并/etc/postgresql/14/main/postgresql.conf在重新启动 PostgreSQL 之前编辑值

    systemctl restart postgresql
    
    • 1
    创建用户

    您需要创建一个 Mastodon 可以使用的 PostgreSQL 用户。在简单的设置中使用“ident”身份验证是最容易的,即 PostgreSQL 用户没有单独的密码,并且可以由具有相同用户名的 Linux 用户使用。

    打开提示:

    sudo -u postgres psql
    
    • 1

    在提示符下,执行:

    CREATE USER mastodon CREATEDB;
    
    • 1

    完毕!

    packages
    apt update
    apt install -y \
      imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \
      g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \
      bison build-essential libssl-dev libyaml-dev libreadline6-dev \
      zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev \
      nginx redis-server redis-tools postgresql postgresql-contrib \
      certbot python3-certbot-nginx libidn11-dev libicu-dev libjemalloc-dev
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    Yarn
    corepack enable
    yarn set version stable
    
    • 1
    • 2
    安装 Ruby

    我们将使用 rbenv 来管理 Ruby 版本,因为更容易获得正确的版本并在新版本发布后进行更新。rbenv 必须为单个 Linux 用户安装,因此,首先我们必须创建用户 Mastodon 将运行为:

    adduser --disabled-login mastodon
    
    • 1

    然后我们可以切换到用户:

    su - mastodon
    
    • 1

    并继续安装 rbenvrbenv-build

    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
    cd ~/.rbenv && src/configure && make -C src
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
    exec bash
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    完成后,我们可以安装正确的 Ruby 版本:

    RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.3
    rbenv global 3.0.3
    
    • 1
    • 2

    我们还需要安装捆绑器:

    gem install bundler --no-document
    
    • 1

    返回root用户:

    exit
    
    • 1

    安装mastodon

    是时候下载 Mastodon 代码了。切换到乳齿象用户:

    su - mastodon
    
    • 1

    检查代码
    使用 git 下载 Mastodon 的最新稳定版本:

    git clone https://github.com/tootsuite/mastodon.git live && cd live
    git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
    
    • 1
    • 2

    安装最后的依赖项

    现在安装 Ruby 和 JavaScript 依赖项:

    bundle config deployment 'true'
    bundle config without 'development test'
    bundle install -j$(getconf _NPROCESSORS_ONLN)
    yarn install --pure-lockfile
    
    • 1
    • 2
    • 3
    • 4

    bundle config仅在您第一次安装依赖项时才需要这两个命令。如果您稍后要更新或重新安装依赖项,就bundle install足够了。

    生成配置

    运行交互式设置向导:

    RAILS_ENV=production bundle exec rake mastodon:setup
    
    • 1

    这将:

    • 创建配置文件
    • 运行资产预编译
    • 创建数据库架构

    配置文件保存为.env.production. 您可以根据自己的喜好查看和编辑它。请参阅有关配置的文档。

    你现在已经完成了 mastodon 用户,所以切换回 root

    exit
    
    • 1

    #####设置 nginx

    从 Mastodon 目录复制 nginx 的配置模板:

    cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
    ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon
    
    • 1
    • 2

    然后编辑/etc/nginx/sites-available/mastodon以替换example.com为您自己的域名,并进行您可能需要的任何其他调整。

    重新加载 nginx 以使更改生效:

    #####获取 SSL 证书

    我们将使用 Let’s Encrypt 获得免费的 SSL 证书:

    certbot --nginx -d example.com
    
    • 1

    这将获取证书,自动更新/etc/nginx/sites-available/mastodon以使用新证书,并重新加载 nginx 以使更改生效。

    此时您应该能够在浏览器中访问您的域,并看到大象撞到计算机屏幕错误页面。这是因为我们还没有开始 Mastodon 进程。

    设置 systemd 服务

    从 Mastodon 目录复制 systemd 服务模板:

    cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
    
    • 1

    如果您在任何时候偏离默认值,请检查用户名和路径是否正确:

    $EDITOR /etc/systemd/system/mastodon-*.service
    
    • 1

    最后,启动并启用新的 systemd 服务:

    systemctl daemon-reload
    systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming
    
    • 1
    • 2

    它们现在将在启动时自动启动。

    欢呼!就是这个。您现在可以在浏览器中访问您的域!

  • 相关阅读:
    高压放大器在软体机器人领域的应用
    入行数字IC验证后会做些什么?需要哪些必备技能?
    Java-数据库操作
    查看docker容器IP地址
    zookeeper本地安装启动
    基于词典的正向最大匹配和逆向最大匹配中文分词
    用上这个建筑管理技巧,我才知道有多省事!
    Linux——进程控制(一)进程的创建与退出
    JS的装箱和拆箱
    [附源码]计算机毕业设计springboot软考刷题小程序
  • 原文地址:https://blog.csdn.net/weixin_40425640/article/details/125975049