From 9beb501bacf1cfe094125c675b198f9e09d241ff Mon Sep 17 00:00:00 2001 From: Janek <27jf@pm.me> Date: Sun, 24 Jan 2021 09:52:33 +0100 Subject: [PATCH] Slight improvements for admin docs (#856) * admin/install: simplify system package instructions & use sh codeblocks No need to assume bash * admin/config: document RAILS_ENV in more detail --- content/en/admin/config.md | 4 ++- content/en/admin/install.md | 62 ++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/content/en/admin/config.md b/content/en/admin/config.md index 004fbdc5..d28b6bce 100644 --- a/content/en/admin/config.md +++ b/content/en/admin/config.md @@ -85,7 +85,9 @@ Generate with `rake mastodon:webpush:generate_vapid_key`. Changing it will break #### `RAILS_ENV` -Environment. Can be `production`, `development`, or `test`. If you are running Mastodon on your personal computer for development purposes, use `development`. That is also the default. If you are running Mastodon online, use `production`. Mastodon will load different configuration defaults based on the environment. +Which Rails environment is loaded from `config/environments`. Can be `production`, `development`, or `test`. +If you are running Mastodon on your personal computer for development purposes, use `development`, which will disable caching. This is also the default. +If you are running Mastodon online, use `production`. {{< hint style="warning" >}} This variable cannot be defined in dotenv (`.env`) files as it's used before they are loaded. diff --git a/content/en/admin/install.md b/content/en/admin/install.md index 8beead3e..9e821236 100644 --- a/content/en/admin/install.md +++ b/content/en/admin/install.md @@ -13,31 +13,16 @@ menu: * A **domain name** \(or a subdomain\) for the Mastodon server, e.g. `example.com` * An e-mail delivery service or other **SMTP server** -You will be running the commands as root. If you aren’t already root, switch to root: +The following commands should be run as root. If you aren’t already root, switch via `su`. ### System repositories {#system-repositories} -Make sure curl is installed first: - -#### Node.js {#node-js} - -```bash -curl -sL https://deb.nodesource.com/setup_12.x | bash - -``` - -#### Yarn {#yarn} - -```bash -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list -``` - ### System packages {#system-packages} -```bash +```sh apt update apt install -y \ - imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \ + curl 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 \ @@ -45,23 +30,36 @@ apt install -y \ certbot python-certbot-nginx yarn libidn11-dev libicu-dev libjemalloc-dev ``` +#### Node.js {#node-js} + +```sh +curl -sL https://deb.nodesource.com/setup_12.x | bash - +``` + +#### Yarn {#yarn} + +```sh +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +``` + ### Installing Ruby {#installing-ruby} We will be using rbenv to manage Ruby versions, because it’s easier to get the right versions and to update once a newer release comes out. rbenv must be installed for a single Linux user, therefore, first we must create the user Mastodon will be running as: -```bash +```sh adduser --disabled-login mastodon ``` We can then switch to the user: -```bash +```sh su - mastodon ``` And proceed to install rbenv and rbenv-build: -```bash +```sh git clone https://github.com/rbenv/rbenv.git ~/.rbenv cd ~/.rbenv && src/configure && make -C src echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc @@ -72,20 +70,20 @@ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build Once this is done, we can install the correct Ruby version: -```bash +```sh RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2 rbenv global 2.7.2 ``` We’ll also need to install bundler: -```bash +```sh gem install bundler --no-document ``` Return to the root user: -```bash +```sh exit ``` @@ -103,7 +101,7 @@ You will need to create a PostgreSQL user that Mastodon could use. It is easiest Open the prompt: -```bash +```sh sudo -u postgres psql ``` @@ -120,7 +118,7 @@ Done! It is time to download the Mastodon code. Switch to the mastodon user: -```bash +```sh su - mastodon ``` @@ -128,7 +126,7 @@ su - mastodon Use git to download the latest stable release of Mastodon: -```bash +```sh 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) ``` @@ -137,7 +135,7 @@ git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1) Now to install Ruby and JavaScript dependencies: -```bash +```sh bundle config deployment 'true' bundle config without 'development test' bundle install -j$(getconf _NPROCESSORS_ONLN) @@ -152,7 +150,7 @@ The two `bundle config` commands are only needed the first time you're installin Run the interactive setup wizard: -```bash +```sh RAILS_ENV=production bundle exec rake mastodon:setup ``` @@ -166,7 +164,7 @@ The configuration file is saved as `.env.production`. You can review and edit it You’re done with the mastodon user for now, so switch back to root: -```bash +```sh exit ``` @@ -174,7 +172,7 @@ exit Copy the configuration template for nginx from the Mastodon directory: -```bash +```sh cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon ``` @@ -187,7 +185,7 @@ Reload nginx for the changes to take effect: We’ll use Let’s Encrypt to get a free SSL certificate: -```bash +```sh certbot --nginx -d example.com ```