在Ubuntu 20.04/18.04上安装Mastodon,并使用Let's加密SSL证书
Mastodon是一个免费的开源自动托管的社交网络服务器,在Agplv3下获得许可。
Mastodon在Twitter的功能中类似的功能,并允许我们在全球互连的微博社区中发布链接,文本,视频和图片并分享。
在这篇文章中,我们将讨论如何在Ubuntu 20.04/18.04 Linux上安装Mastodon,并使用Let's加密SSL证书。
Mastodon具有必须安装的许多依赖项。
它们包括Ruby,PostgreSQL,Node.js,Yarn,Redis,Nginx 等我们的步骤将讨论在Ubuntu 20.04/18.04 LTS上拥有运行Mastodon所需的所有步骤。
设置要求
在Ubuntu 20.04/18.04 Linux上设置Mastodon时,需要以下软件。
PostgreSQL 9.5+
redis.
Ruby 2.4+
node.js 8+
我们假设我们也有以下内容。
运行Ubuntu 20.04/18.04机器
Mastodon Server的域名(或者子域),例如: example.com或者seameaum.example.com.
用于通知的电子邮件传送服务或者其他SMTP服务器。
第1步:更新系统
确保服务器已更新:
sudo apt -y update && sudo apt -y upgrade sudo reboot
第2步:安装node.js&yarn
安装node.js.
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash sudo apt-get install -y nodejs
通过检查版本确认成功安装:
$nodejs --version v8.10.0
安装纱线:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add echo "deb https://dl.yarnpkg.com/debian/stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update sudo apt -y install yarn
第3步:安装其他依赖性包
在Ubuntu 20.04/18.04上运行Mastodon需要许多系统依赖性包。
让我们确保在本地安装这些包。
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 libgdbm5 libgdbm-dev nginx redis-server redis-tools certbot python-certbot-nginx yarn libidn11-dev libicu-dev libjemalloc-dev
第4步:安装Ruby
运行Ruby的首选方法是使用rbenv,因为它允许我们轻松管理多个版本。
我们将创建一个用于这些操作的Mastodon用户。
sudo adduser --disabled-login mastodon sudo 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 2.6.5 rbenv global 2.6.5
Ruby_2.6.0附带的默认宝石版本与最新的Bundler不兼容,因此我们需要更新宝石并安装Bundler。
gem update --system gem install bundler --no-document exit
第5步:安装PostgreSQL数据库服务器
使用我们的PostgreSQL安装教程:
安装PostgreSQL数据库Ubuntu
创建用户:
sudo -u postgres psql CREATE USER mastodon CREATEDB; \q
第6步:设置Mastodon
是时候下载Mastodon代码了。
从root或者用户帐户切换到Mastodon用户:
sudo apt -y install git sudo su - mastodon
克隆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)
安装上次依赖项:
gem install bundler:1.17.3 bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test yarn install --pure-lockfile
运行交互式向导以生成配置:
RAILS_ENV=production bundle exec rake mastodon:setup
填写所需信息:
/home/mastodon/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated Your instance is identified by its domain name. Changing it afterward will break things. Domain name: example.com Single user mode disables registrations and redirects the landing page to your public profile. Do you want to enable single user mode? yes Are you using Docker to run Mastodon? no PostgreSQL host: /var/run/postgresql PostgreSQL port: 5432 Name of PostgreSQL database: mastodon_production Name of PostgreSQL user: mastodon Password of PostgreSQL user: Database configuration works!