恒创科技

广告

hostinger

广告

RackNerd VPS部署Mastodon实例指南

美国云服务器推荐

Mastodon是一个开源、去中心化的社交平台,属于Fediverse网络的一部分。与传统社交平台依赖单一服务器不同,Mastodon允许任何人托管自己的实例,同时仍可以与其他实例上的用户互动。你可以完全掌控自己的数据和社区规则。RackNerd提供高性能、稳定的VPS方案,适合托管Mastodon实例。下文主要介绍RackNerd VPS部署Mastodon详细过程。

一、购买RackNerd VPS

在开始之前,请先购买符合以下条件的RackNerd VPS:

  • 4GB内存(建议8GB)
  • 2个vCPU
  • 40–60GB磁盘空间

购买RackNerd VPS优惠方案

方案 CPU 内存 SSD存储 月流量 端口 价格 购买链接
1GB KVM VPS 1核 1GB 20GB SSD 3TB 1Gbps $21.99/年 点击购买
2GB KVM VPS 2核 2GB 35GB SSD 5TB 1Gbps $35.99/年 点击购买
4GB KVM VPS 3核 4GB 60GB SSD 7TB 1Gbps $59.99/年 点击购买
6GB KVM VPS 6核 6GB 100GB SSD 12TB 1Gbps $89.99/年 点击购买
8GB KVM VPS 7核 8GB 150GB SSD 20TB 1Gbps $119.99/年 点击购买

评测参考:

教程:RackNerd KVM VPS购买图文教程

域名:一个可访问的域名,用于你的Mastodon实例

若还没有域名,推荐访问Gname官网注册,新客立享5张.com域名注册券,无需领取注册自动方法。

二、RackNerd VPS部署Mastodon步骤

1、更新服务器

首先更新你的服务器系统及软件包:

sudo apt update && sudo apt upgrade -y

安装必要依赖:

sudo apt install git curl nano gnupg apt-transport-https build-essential -y

2、安装PostgreSQL

PostgreSQL是Mastodon的数据库后端。

sudo apt install postgresql postgresql-contrib -y

创建数据库和用户:

sudo -u postgres psql

在PostgreSQL Shell内执行:

CREATE USER mastodon WITH PASSWORD ‘yourpassword’; CREATE DATABASE mastodon_production OWNER mastodon;
\q

3、安装Redis

Redis用于缓存和后台任务队列。

sudo apt install redis-server -y
sudo systemctl enable redis-server
sudo systemctl start redis-server

4、安装Node.js和Yarn

Mastodon前端依赖Node.js。

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash –
sudo apt install -y nodejs

安装Yarn:

corepack enable
corepack prepare yarn@stable –activate

5、安装Ruby(通过rbenv或RVM)

示例使用rbenv:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bashrc source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
gitclonehttps://github.com/rbenv/ruby-build.git~/.rbenv/plugins/ruby-build

rbenv install 3.2.2
rbenv global 3.2.2

6、安装Mastodon

克隆Mastodon源码:

git clone https://github.com/mastodon/mastodon.git
cd mastodon
git checkout $(git tag | sort -V | tail -1)

安装Ruby gems:

bundle install

安装JavaScript依赖:

Install JavaScript dependencies:
yarn install –production

7、配置Mastodon

创建环境配置文件:

cp .env.production.sample .env.production
vi .env.production

编辑关键配置项:

  • LOCAL_DOMAIN:你的域名
  • PostgreSQL用户名和密码
  • Redis URL
  • 邮件发送设置
  • 媒体存储路径

然后运行数据库迁移和前端资源编译:

RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails assets:precompile

8、配置Nginx与SSL

安装Nginx:

sudo apt install nginx -y

创建Mastodon Nginx配置文件:

sudovi/etc/nginx/sites-available/mastodon

启用并重启Nginx:

sudo ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/
sudo systemctl restart nginx

启用HTTPS(Certbot自动获取证书):

sudo apt install certbot python3-certbot-nginx -y
sudo certbot –nginx -d yourdomain.com

9、设置Mastodon服务

创建systemd服务文件:

mastodon-web
mastodon-streaming
mastodon-sidekiq

启用并启动服务:

sudo systemctl enable –now mastodon-web mastodon-sidekiq mastodon-streaming
sudo systemctl status mastodon-web

10、访问你的Mastodon实例

完成后,打开浏览器访问:

https://yourdomain.com

注册管理员账号,即可开始管理和配置你的Mastodon社区。

相关推荐:

RackNerd国外VPS安装和配置GitLab完整教程

RackNerd cPanel主机AI网站生成器快速搭建教程

RackNerd国外Ubuntu VPS通过WordOps安装WordPress教程

(本文由美国主机侦探原创,转载请注明出处“美国主机侦探”和原文地址!)

主机侦探企业微信

微信扫码加好友进群

主机优惠码及时掌握

主机侦探QQ群

QQ群号:164393063

主机优惠发布与交流

温馨提示:

1、本站部分图片来源于互联网,如有侵权请联系删除。邮箱:2942802716#qq.com(#改为@)

2、本文评论没有专人回复,如果您有问题请到美国主机侦探论坛提问!

3、美国主机侦探免费为您提供美国主机购买咨询。

RAKsmart美国服务器
返回顶部