《开源精选》是我们分享GitHub、Gitee等开源社区中优质项目的栏目,包括技术、学习、实用与各种有趣的内容。本期推荐的Mastodon 是一个基于 ActivityPub 的免费开源社交网络服务器,用户可以在其中关注朋友并发现新朋友。

spring 集成平台(Mastodon一个基于ActivityPub)(1)

在 Mastodon 上,用户可以发布他们想要的任何内容:链接、图片、文本、视频。所有 Mastodon 服务器都可以作为联合网络进行互操作(一台服务器上的用户可以与另一台服务器上的用户无缝通信,包括实现 ActivityPub 的非 Mastodon 软件)!

Mastodon特征Mastodon部署

技术栈:

要求:

运行Mastodon

1 准备您的机器

首先确保您实际上是使用密钥而不是通过密码登录服务器,否则这会将您锁定在外。许多托管服务提供商支持上传公钥并为您在新机器上自动设置基于密钥的 root 登录。

编辑/etc/ssh/sshd_config并查找PasswordAuthentication. 确保它未注释并设置为no. 如果您进行了任何更改,请重新启动 sshd:

systemctl restart ssh.service

2 更新系统包

apt update && apt upgrade -y

3 安装 fail2ban 以阻止重复登录尝试

apt install fail2ban

编辑/etc/fail2ban/jail.local并将其放入:

[DEFAULT] destemail = your@email.here sendername = Fail2Ban [sshd] enabled = true port = 22 [sshd-ddos] enabled = true port = 22

最后重启fail2ban:

systemctl restart fail2ban

从源安装

先决条件

您将以 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

节点.js

curl -sL https://deb.nodesource.com/setup_16.x | bash -

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

安装 Ruby

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

adduser --disabled-login mastodon

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

su - mastodon

并继续安装 rbenv 和 rbenv-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

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

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.3 rbenv global 3.0.3

我们还需要安装捆绑器:

gem install bundler --no-document

返回root用户:

exit

升级到新版本

首先,切换到mastodon用户:

su - mastodon

并导航到 Mastodon 根目录:

cd /home/mastodon/live

下载版本的代码,假设版本被调用v3.1.2:

git fetch --tags git checkout v3.1.2

现在执行 GitHub 上该版本的发行说明中包含的升级说明。由于不同的版本需要不同的说明,因此我们在此页面上不包含任何说明。

执行发行说明中的​说明后,切换回 root:

exit

重启后台工作者:

systemctl restart mastodon-sidekiq

并重新加载网络进程:

systemctl reload mastodon-web

开源协议:AGPL-3.0 license

开源地址:https://github.com/mastodon/mastodon

,