这篇文章是在digitalocean的2C 2G Debian 11 x64服务器下部署的,此时的mastodon版本为4.1.2。
以下命令均以一个非root但具有sudo权限的用户的身份执行。
准备环境
1.保持系统最新、安装必要软件包
1 2 3
| sudo apt update sudo apt upgrade sudo apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates
|
在实践过程中第三条命令似乎不会造成任何改动
2.安装Node 16.x
1 2 3 4 5
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash source ~/.bashrc nvm install --lts=gallium nvm use lts/gallium node -v
|
在实践过程中直接添加apt源并安装的方式似乎会出现报错
3.安装Postgresql和Redis
1 2 3 4
| sudo wget -O /usr/share/keyrings/postgresql.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc sudo 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 sudo apt update sudo apt install postgresql redis-server
|
4.补充安装Mastodon文档要求的其它包
1 2 3 4 5 6 7 8
| sudo apt update 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 libgdbm-dev \ nginx redis-server redis-tools postgresql postgresql-contrib \ certbot python3-certbot-nginx libidn11-dev libicu-dev libjemalloc-dev
|
5.安装Yarn
1 2 3
| npm install --global yarn corepack enable yarn set version classic
|
6.安装Ruby
1 2 3 4 5 6 7 8 9 10
| cd 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_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.6 rbenv global 3.0.6 gem install bundler --no-document
|
注意:随着mastodon版本变化,需要的rbenv版本也随之改变
安装过程可能需要耗费相当长时间
7.创建数据库用户
在输入下面的SQL语句时,请注意替换对应的用户名及密码。如保持USER字段为mastodon不变,后续可能出现使用密码无法登录的情况(不保证不是因为我输错密码)
1 2
| CREATE USER mastodon PASSWORD 'XXXXXXX' CREATEDB; \q
|
部署Mastodon
1.拉取源码存储库
1 2 3
| cd git clone https://github.com/mastodon/mastodon.git live && cd live git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
|
2.安装依赖