Skip to content

Installation

Kyrch edited this page Jan 9, 2025 · 36 revisions

Note: WIP. Please contact staff in the Discord for corrections or missing information.


This guide exists to help developers set up a local instance of AnimeThemes.

Prerequisites

  • A webserver such as Apache or Nginx
  • PHP 8.4
  • An RDBMS such as MySQL, PostgreSQL or SQLite
  • composer for vendor dependencies

A LAMP stack, such as XAMPP, can also be used to set up Apache, MySQL, and PHP.

Setup

Clone the repository in the webserver's htdocs/ or www/ directory.

git clone git@github.com:AnimeThemes/animethemes-server.git
cd animethemes-server

Copy the contents of the .env.example file to a new file .env.

Web Server

Next, we will configure our web server here to serve the application.

Database

Next, we will create the database for our development environment. Follow the configuration guide here to define the database connection.

PHP

Required Extensions

We should ensure that we have the following extensions enabled for php. This can be verified in the php.ini file in our installation.

fileinfo - Needed to detect MIME type of files during seeding.

gd - Needed to fake image files for testing.

pdo_mysql - Needed to use MySQL.

Required Configuration

In order to accept video uploads, we should ensure that php will accept requests of adequate sizes. This can be verified in the php.ini file in our installation.

Set post_max_size to 200M.

Set upload_max_filesize to 200M.

Configuration

Ensure that the .env file has been created from the .env.example stub file. The .env file will be provided with sensible default values from the example file. Features that require external services are disabled by default.

Development needs will vary depending on the work being done. The list of custom configuration options can be found here for review.

Required

Run php artisan key:generate to set a value for APP_KEY.

Optional

Here we will review the configuration options for enabling additional features.

If we want to enable video streams, we need to set the App\Features\AllowVideoStreams value on DB to true. We recommend setting up a local archive for the videos_local disk.

If we want to enable discord notifications, we need to set the allow_discord_notifications value on DB to true. We will need to configure a Queue to process the dispatched events through a worker. Finally, we will need to create a Discord application and register it config/services.php.

If we want to enable scout, we need to configure Elasticsearch.

Installation

  • Install vendor dependencies with composer install in the project root directory.

  • Import database from the animethemes-db-dump-*.sql wiki dump for the targeted release. Database dumps are hosted here.

  • Migrate the database with php artisan migrate.

  • Seed the database with php artisan db:seed --class=DatabaseSeeder

  • If we have configured Elasticsearch, ensure an instance is running and execute the index migrations with php artisan elastic:migrate.

  • If we have configured Elasticsearch, import models into our indices using:

# Import Models with a seeder
php artisan db:seed --class="Database\Seeders\Scout\ImportModelsSeeder"

# or
# Import Models manually
php artisan scout:import "App\Models\List\Playlist"
php artisan scout:import "App\Models\Wiki\Anime"
php artisan scout:import "App\Models\Wiki\Anime\AnimeSynonym"
php artisan scout:import "App\Models\Wiki\Anime\AnimeTheme"
php artisan scout:import "App\Models\Wiki\Anime\Theme\AnimeThemeEntry"
php artisan scout:import "App\Models\Wiki\Artist"
php artisan scout:import "App\Models\Wiki\Series"
php artisan scout:import "App\Models\Wiki\Song"
php artisan scout:import "App\Models\Wiki\Studio"
php artisan scout:import "App\Models\Wiki\Video"

Local Storage

We are not required to set up s3 buckets in order to interact with media. We have the option to configure local filesystems that we can stream audio/video from and download scripts/dumps from.

Configure local filesystem disks in .env

AUDIO_DISK_DEFAULT=audios_local
AUDIO_DISKS=audios_local
...
DUMP_DISK=dumps_local
...
IMAGE_DISK=images_local
...
VIDEO_DISK_DEFAULT=videos_local
VIDEO_DISKS=videos_local
...
SCRIPT_DISK=scripts_local

By default, app storage directories will be used to store media. External directories can be specified as the root if media is stored elsewhere.

Remark: It is recommended to include a .gitignore at the root directory of the filesystem so that media files are not indexed by git.

AUDIO_DISK_ROOT="E:\\animethemes-audios\\"
...
DUMP_DISK_ROOT="E:\\animethemes-db-dumps\\"
...
IMAGE_DISK_ROOT="E:\\animethemes-images\\"
...
SCRIPT_DISK_ROOT="E:\\animethemes-scripts\\"
...
VIDEO_DISK_ROOT="E:\\animethemes-videos\\"

Create symbolic links to target storage directories.

php artisan storage:link

Running

After installation, restart the web server to apply the configuration.

If all went well, AnimeThemes should be live at http://animethemes.test (or whatever set the server name is set to).