## Packages Last updated: Roughly March 30, 2022 Assumption: Ubuntu 21.04. ```shell # ElasticSearch repo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list # PostgreSQL repo wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list apt update apt upgrade # doesn't hurt apt install apt-transport-https git build-essential cmake default-jre \ libcurl4-openssl-dev libicu-dev libopencv-dev libpq-dev libreadline-dev libxml2-dev \ libbison-dev libffi-dev libgdbm-dev libncurses5-dev libssl-dev libyaml-dev libmagic-dev \ gifsicle optipng libjpeg-progs \ nodejs redis-server nginx postgresql-13 elasticsearch ``` ### Custom ffmpeg Custom ffmpeg is needed because upstream has some bugs with certain image formats - this fork fixes them. You may want to do this building on a separate box, to avoid polluting production with everything `apt build-dep ffmpeg` will pull in. ```shell # uncomment the deb-src lines in /etc/apt/sources.list apt update apt build-dep ffmpeg git clone https://github.com/philomena-dev/FFmpeg.git cd FFmpeg git checkout release/5.0 # commit 43f43e6290fcacd77e256ae668d9ff8cf10a5551 is known to work ./configure --prefix=/usr/local --disable-xlib --enable-avfilter --enable-gpl --enable-libmp3lame --enable-libvorbis \ --enable-libvpx --enable-libx264 --enable-libx265 --enable-postproc --enable-pic --enable-pthreads \ --enable-shared --disable-stripping --disable-static --disable-librtmp --enable-libopus --enable-librsvg \ --enable-libwebp make -j$(nproc) # or whatever you like make install ```` ### mediatools Used by the app for detecting image formats and generating thumbnails. ```shell git clone https://github.com/Twibooru/mediatools.git cd mediatools make && make install ``` ### ImageMagick Ubuntu doesn't package new enough ImageMagick for us. Someone made a handy script called IMEI that will install it for us. ```shell git clone https://github.com/SoftCreatR/imei cd imei ./imei.sh ``` ## Configuration ### ElasticSearch Edit `/etc/elasticsearch/elasticsearch.yml` to change memory allocation and such if desired. Production has 64GB of RAM and allocates 8GB to ES. Also, change `enabled: true` under `xpack.security.http.ssl` to `enabled: false`. `systemctl enable elasticsearch && systemctl start elasticsearch` `/usr/share/elasticsearch/bin/elasticsearch-reset-password -a -u elastic` and save the generated password. ### Redis Defaults are fine `systemctl enable redis && systemctl start redis` ### PostgreSQL Edit `/etc/postgresql/12/main/pg_hba.conf`, make sure local users don't need authentication, change the following: ``` # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 ``` to look like this: ``` # IPv4 local connections: host all all 127.0.0.1/32 trust # <--- this changed # IPv6 local connections: host all all ::1/128 trust # <--- and this ``` If you are in production, punch your server specs into `https://pgtune.leopard.in.ua/` and use the recommended params. `systemctl enable elasticsearch && systemctl start elasticsearch` ```shell su - postgres createuser twibooru --createdb ``` ### Nginx Copy nginx/nginx.conf to `/etc/nginx/nginx.conf` and nginx/twibooru.conf to `/etc/nginx/conf.d/twibooru.conf` and edit as desired. If you're behind a reverse proxy over a private network, change the listen host to not be 0.0.0.0 and make sure to setup the NGINX realip module appropriately. `systemctl enable nginx && systemctl start nginx` ## Ruby Follow the instructions at to install chruby and ruby-install, using chruby **0.3.9** and ruby-install **0.8.3**. `ruby-install ruby 3.1.1` ## App **Change to the app user** `su - twibooru` ```shell cat >> ~/.$(basename $SHELL)rc <