logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

centos7_en.md (7725B)


      1 # Installing on CentOS 7
      2 ## Installation
      3 
      4 This guide is a step-by-step installation guide for CentOS 7. It also assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
      5 
      6 ### Required packages
      7 
      8 * `postgresql` (9,6+, CentOS 7 comes with 9.2, we will install version 11 in this guide)
      9 * `elixir` (1.5+)
     10 * `erlang`
     11 * `erlang-parsetools`
     12 * `erlang-xmerl`
     13 * `git`
     14 * Development Tools
     15 
     16 #### Optional packages used in this guide
     17 
     18 * `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
     19 * `certbot` (or any other ACME client for Let’s Encrypt certificates)
     20 
     21 ### Prepare the system
     22 
     23 * First update the system, if not already done:
     24 
     25 ```shell
     26 sudo yum update
     27 ```
     28 
     29 * Install some of the above mentioned programs:
     30 
     31 ```shell
     32 sudo yum install wget git unzip
     33 ```
     34 
     35 * Install development tools:
     36 
     37 ```shell
     38 sudo yum group install "Development Tools"
     39 ```
     40 
     41 ### Install Elixir and Erlang
     42 
     43 * Add the EPEL repo:
     44 
     45 ```shell
     46 sudo yum install epel-release
     47 sudo yum -y update
     48 ```
     49 
     50 * Install Erlang repository:
     51 
     52 ```shell
     53 wget -P /tmp/ https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
     54 sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
     55 ```
     56 
     57 * Install Erlang:
     58 
     59 ```shell
     60 sudo yum install erlang erlang-parsetools erlang-xmerl
     61 ```
     62 
     63 * Download [latest Elixir release from Github](https://github.com/elixir-lang/elixir/releases/tag/v1.8.1) (Example for the newest version at the time when this manual was written)
     64 
     65 ```shell
     66 wget -P /tmp/ https://github.com/elixir-lang/elixir/releases/download/v1.8.1/Precompiled.zip
     67 ```
     68 
     69 * Create folder where you want to install Elixir, we’ll use:
     70 
     71 ```shell
     72 sudo mkdir -p /opt/elixir
     73 ```
     74 
     75 * Unzip downloaded file there:
     76 
     77 ```shell
     78 sudo unzip /tmp/Precompiled.zip -d /opt/elixir
     79 ```
     80 
     81 * Create symlinks for the pre-compiled binaries:
     82 
     83 ```shell
     84 for e in elixir elixirc iex mix; do sudo ln -s /opt/elixir/bin/${e} /usr/local/bin/${e}; done
     85 ```
     86 
     87 ### Install PostgreSQL
     88 
     89 * Add the Postgresql repository:
     90 
     91 ```shell
     92 sudo yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
     93 ```
     94 
     95 * Install the Postgresql server:
     96 
     97 ```shell
     98 sudo yum install postgresql11-server postgresql11-contrib
     99 ```
    100 
    101 * Initialize database:
    102 
    103 ```shell
    104 sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
    105 ```
    106 
    107 * Open configuration file `/var/lib/pgsql/11/data/pg_hba.conf` and change the following lines from:
    108 
    109 ```plain
    110 # IPv4 local connections:
    111 host    all             all             127.0.0.1/32            ident
    112 # IPv6 local connections:
    113 host    all             all             ::1/128                 ident
    114 ```
    115 
    116 to
    117 
    118 ```plain
    119 # IPv4 local connections:
    120 host    all             all             127.0.0.1/32            md5
    121 # IPv6 local connections:
    122 host    all             all             ::1/128                 md5
    123 ```
    124 
    125 * Enable and start postgresql server:
    126 
    127 ```shell
    128 sudo systemctl enable --now postgresql-11.service
    129 ```
    130 
    131 ### Install PleromaBE
    132 
    133 * Add a new system user for the Pleroma service:
    134 
    135 ```shell
    136 sudo useradd -r -s /bin/false -m -d /var/lib/pleroma -U pleroma
    137 ```
    138 
    139 **Note**: To execute a single command as the Pleroma system user, use `sudo -Hu pleroma command`. You can also switch to a shell by using `sudo -Hu pleroma $SHELL`. If you don’t have and want `sudo` on your system, you can use `su` as root user (UID 0) for a single command by using `su -l pleroma -s $SHELL -c 'command'` and `su -l pleroma -s $SHELL` for starting a shell.
    140 
    141 * Git clone the PleromaBE repository and make the Pleroma user the owner of the directory:
    142 
    143 ```shell
    144 sudo mkdir -p /opt/pleroma
    145 sudo chown -R pleroma:pleroma /opt/pleroma
    146 sudo -Hu pleroma git clone -b stable https://git.pleroma.social/pleroma/pleroma /opt/pleroma
    147 ```
    148 
    149 * Change to the new directory:
    150 
    151 ```shell
    152 cd /opt/pleroma
    153 ```
    154 
    155 * Install the dependencies for Pleroma and answer with `yes` if it asks you to install `Hex`:
    156 
    157 ```shell
    158 sudo -Hu pleroma mix deps.get
    159 ```
    160 
    161 * Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
    162   * Answer with `yes` if it asks you to install `rebar3`.
    163   * This may take some time, because parts of pleroma get compiled first.
    164   * After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
    165 
    166 * Check the configuration and if all looks right, rename it, so Pleroma will load it (`prod.secret.exs` for productive instance, `dev.secret.exs` for development instances):
    167 
    168 ```shell
    169 mv config/{generated_config.exs,prod.secret.exs}
    170 ```
    171 
    172 * The previous command creates also the file `config/setup_db.psql`, with which you can create the database:
    173 
    174 ```shell
    175 sudo -Hu postgres psql -f config/setup_db.psql
    176 ```
    177 
    178 * Now run the database migration:
    179 
    180 ```shell
    181 sudo -Hu pleroma MIX_ENV=prod mix ecto.migrate
    182 ```
    183 
    184 * Now you can start Pleroma already
    185 
    186 ```shell
    187 sudo -Hu pleroma MIX_ENV=prod mix phx.server
    188 ```
    189 
    190 ### Finalize installation
    191 
    192 If you want to open your newly installed instance to the world, you should run nginx or some other webserver/proxy in front of Pleroma and you should consider to create a systemd service file for Pleroma.
    193 
    194 #### Nginx
    195 
    196 * Install nginx, if not already done:
    197 
    198 ```shell
    199 sudo yum install nginx
    200 ```
    201 
    202 * Setup your SSL cert, using your method of choice or certbot. If using certbot, first install it:
    203 
    204 ```shell
    205 sudo yum install certbot-nginx
    206 ```
    207 
    208 and then set it up:
    209 
    210 ```shell
    211 sudo mkdir -p /var/lib/letsencrypt/
    212 sudo certbot certonly --email <your@emailaddress> -d <yourdomain> --standalone
    213 ```
    214 
    215 If that doesn’t work, make sure, that nginx is not already running. If it still doesn’t work, try setting up nginx first (change ssl “on” to “off” and try again).
    216 
    217 ---
    218 
    219 * Copy the example nginx configuration to the nginx folder
    220 
    221 ```shell
    222 sudo cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/conf.d/pleroma.conf
    223 ```
    224 
    225 * Before starting nginx edit the configuration and change it to your needs (e.g. change servername, change cert paths)
    226 * Enable and start nginx:
    227 
    228 ```shell
    229 sudo systemctl enable --now nginx
    230 ```
    231 
    232 If you need to renew the certificate in the future, uncomment the relevant location block in the nginx config and run:
    233 
    234 ```shell
    235 sudo certbot certonly --email <your@emailaddress> -d <yourdomain> --webroot -w /var/lib/letsencrypt/
    236 ```
    237 
    238 #### Other webserver/proxies
    239 
    240 You can find example configurations for them in `/opt/pleroma/installation/`.
    241 
    242 #### Systemd service
    243 
    244 * Copy example service file
    245 
    246 ```shell
    247 sudo cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
    248 ```
    249 
    250 * Edit the service file and make sure that all paths fit your installation
    251 * Enable and start `pleroma.service`:
    252 
    253 ```shell
    254 sudo systemctl enable --now pleroma.service
    255 ```
    256 
    257 #### Create your first user
    258 
    259 If your instance is up and running, you can create your first user with administrative rights with the following task:
    260 
    261 ```shell
    262 sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
    263 ```
    264 
    265 #### Further reading
    266 
    267 * [Backup your instance](../administration/backup.md)
    268 * [Hardening your instance](../configuration/hardening.md)
    269 * [How to activate mediaproxy](../configuration/howto_mediaproxy.md)
    270 * [Updating your instance](../administration/updating.md)
    271 
    272 ## Questions
    273 
    274 Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.