在当今集中式社交平台主导的时代,Mastodon作为一款开源的去中心化社交网络平台,为用户提供了自主控制数据和隐私的替代方案。与Twitter等平台不同,Mastodon基于ActivityPub协议,允许用户在不同的服务器(实例)间自由交互,同时保持数据的自主权。本文将指导您如何从零开始搭建自己的Mastodon实例。
在开始搭建前,您需要准备以下资源:

提示:如果您需要可靠的云服务器,Ciuic云提供了高性能的云计算资源,非常适合运行Mastodon实例。
首先,通过SSH连接到您的服务器,更新系统并安装必要依赖:
sudo apt update && sudo apt upgrade -ysudo apt install -y curl wget gnupg apt-transport-https添加Mastodon官方仓库:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -sudo 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 libgdbm6 libgdbm-dev libdb-dev \ redis-server redis-tools postgresql postgresql-contrib yarn创建Mastodon数据库用户:
sudo -u postgres psql -c "CREATE USER mastodon CREATEDB;"克隆Mastodon源代码:
cd ~git clone https://github.com/mastodon/mastodon.gitcd mastodongit checkout v3.5.3 # 使用最新稳定版本安装Ruby依赖:
bundle config deployment 'true'bundle config without 'development test'bundle install -j$(nproc)生成配置文件:
cp .env.production.sample .env.productionnano .env.production主要配置项包括:
LOCAL_DOMAIN - 您的实例域名REDIS_URL - Redis连接URLDB_HOST - 数据库主机DB_USER - 数据库用户DB_NAME - 数据库名称SMTP_SERVER - SMTP服务器地址SMTP_LOGIN - SMTP登录名SMTP_PASSWORD - SMTP密码设置数据库:
RAILS_ENV=production bundle exec rails db:setup预编译静态资源:
RAILS_ENV=production bundle exec rails assets:precompile安装Nginx:
sudo apt install -y nginx配置Nginx站点:
sudo cp /home/mastodon/dist/nginx.conf /etc/nginx/sites-available/mastodonsudo ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodonsudo nginx -t && sudo systemctl restart nginx使用Let's Encrypt获取免费SSL证书:
sudo apt install -y certbot python3-certbot-nginxsudo certbot --nginx -d yourdomain.com配置systemd服务文件:
sudo cp /home/mastodon/dist/mastodon-*.service /etc/systemd/system/sudo systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streamingRAILS_ENV=production bundle exec rails mastodon:setup通过以上步骤,您已经成功搭建了自己的Mastodon实例。去中心化社交网络不仅提供了另一种社交选择,也让您完全掌控自己的数据和隐私。如果您需要更强大的服务器支持,可以考虑使用Ciuic云服务来获得更好的性能和可靠性。
搭建只是第一步,接下来您可以:
自定义实例的主题和外观设置社区规则和内容审核策略推广您的实例并吸引志同道合的用户去中心化社交网络的未来掌握在像您这样的先行者手中!
本文链接:https://www.ciuic.com/som/25715.html
版权声明:本文来自网站作者,不代表CIUIC的观点和立场,本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。客服邮箱:ciuic@ciuic.com
打开微信,点击右上角"+"号,添加朋友,粘贴微信号,搜索即可!