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
This commit is contained in:
Janek 2021-01-24 09:52:33 +01:00 committed by GitHub
parent 8fa91d1719
commit 9beb501bac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 33 deletions

View File

@ -85,7 +85,9 @@ Generate with `rake mastodon:webpush:generate_vapid_key`. Changing it will break
#### `RAILS_ENV` #### `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" >}} {{< hint style="warning" >}}
This variable cannot be defined in dotenv (`.env`) files as it's used before they are loaded. This variable cannot be defined in dotenv (`.env`) files as it's used before they are loaded.

View File

@ -13,31 +13,16 @@ menu:
* A **domain name** \(or a subdomain\) for the Mastodon server, e.g. `example.com` * A **domain name** \(or a subdomain\) for the Mastodon server, e.g. `example.com`
* An e-mail delivery service or other **SMTP server** * An e-mail delivery service or other **SMTP server**
You will be running the commands as root. If you arent already root, switch to root: The following commands should be run as root. If you arent already root, switch via `su`.
### System repositories {#system-repositories} ### 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} ### System packages {#system-packages}
```bash ```sh
apt update apt update
apt install -y \ 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 \ g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \
bison build-essential libssl-dev libyaml-dev libreadline6-dev \ bison build-essential libssl-dev libyaml-dev libreadline6-dev \
zlib1g-dev libncurses5-dev libffi-dev libgdbm-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 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} ### Installing Ruby {#installing-ruby}
We will be using rbenv to manage Ruby versions, because its 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: We will be using rbenv to manage Ruby versions, because its 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 adduser --disabled-login mastodon
``` ```
We can then switch to the user: We can then switch to the user:
```bash ```sh
su - mastodon su - mastodon
``` ```
And proceed to install rbenv and rbenv-build: And proceed to install rbenv and rbenv-build:
```bash ```sh
git clone https://github.com/rbenv/rbenv.git ~/.rbenv git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc 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: Once this is done, we can install the correct Ruby version:
```bash ```sh
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2 RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2
rbenv global 2.7.2 rbenv global 2.7.2
``` ```
Well also need to install bundler: Well also need to install bundler:
```bash ```sh
gem install bundler --no-document gem install bundler --no-document
``` ```
Return to the root user: Return to the root user:
```bash ```sh
exit exit
``` ```
@ -103,7 +101,7 @@ You will need to create a PostgreSQL user that Mastodon could use. It is easiest
Open the prompt: Open the prompt:
```bash ```sh
sudo -u postgres psql sudo -u postgres psql
``` ```
@ -120,7 +118,7 @@ Done!
It is time to download the Mastodon code. Switch to the mastodon user: It is time to download the Mastodon code. Switch to the mastodon user:
```bash ```sh
su - mastodon su - mastodon
``` ```
@ -128,7 +126,7 @@ su - mastodon
Use git to download the latest stable release of 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 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) 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: Now to install Ruby and JavaScript dependencies:
```bash ```sh
bundle config deployment 'true' bundle config deployment 'true'
bundle config without 'development test' bundle config without 'development test'
bundle install -j$(getconf _NPROCESSORS_ONLN) 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: Run the interactive setup wizard:
```bash ```sh
RAILS_ENV=production bundle exec rake mastodon:setup 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
Youre done with the mastodon user for now, so switch back to root: Youre done with the mastodon user for now, so switch back to root:
```bash ```sh
exit exit
``` ```
@ -174,7 +172,7 @@ exit
Copy the configuration template for nginx from the Mastodon directory: Copy the configuration template for nginx from the Mastodon directory:
```bash ```sh
cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/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:
Well use Lets Encrypt to get a free SSL certificate: Well use Lets Encrypt to get a free SSL certificate:
```bash ```sh
certbot --nginx -d example.com certbot --nginx -d example.com
``` ```