# Installation

The **dms+** application can be installed in two different ways. Please refer to the respective chapters for further details:

* [Docker](#docker)
* [Standalone](#standalone)

## Docker

You can install the **dms+** application in a docker container network. This section describes how to do that.

### Prerequisites

* You must have administrator privileges on the machine where you want to execute the application
* You need to have an installation of the docker engine and docker compose (see [docker compose installation](https://docs.docker.com/compose/install)) on the machine where you want to execute the application

### Installation

Download the latest release and put all files and subfolders from the `_environment` directory to a location of your choice on your hard drive.

### Configuration

Rename the file `dms.env.example` to `dms.env` and adjust the included environment variables for the MySQL connection:

```
# dms.env

MYSQL_DATABASE=myDatabase
MYSQL_USER=dmsAdmin
MYSQL_PASSWORD=aHard2GuessPwd
```

### Startup

Start the docker containers via a terminal window with the following script that automatically handles all necessary docker commands for you:

`sh ./dms-restart.sh`

After a while, you should see the following output in the terminal:

```
Creating database ... done
Creating app      ... done
Creating webserver ... done
Creating scanner   ... done
```

This indicates that the start up was successful. Please continue with the section [Smoketest](#smoketest) in order to check if everything went well.

## Standalone

If you don't want to use the pre-configured docker compose files to run your installation of **dms+**, then you can also install application as standalone version. This section describes how to do that.

### Prerequisites

* You must have administrator privileges on your machine
* You need to make sure that the following packages are installed on your machine: `build-essential`, `gd`, `libpng-dev`, `libjpeg62-turbo-dev`, `libfreetype6-dev`, `locales`, `libzip-dev`, `zip`, `jpegoptim`, `optipng`, `pngquant`, `gifsicle`, `vim`, `unzip`, `git`, `curl`, `netcat`, `pdo_mysql`, `mbstring`, `exif` and `pcntl`
* You need a running [MySQL](https://dev.mysql.com/doc/) server version 8.0 or higher
* You need a running [PHP](https://www.php.net/) server version 7.3 or higher with Apache (alternatively you can use a corresponding [PHP FPM](https://php-fpm.org/) version fronted by [Nginx](https://www.nginx.com/resources/wiki/) version 1.17 or higher)
* You need an installation of [OCRmyPDF](https://github.com/jbarlow83/OCRmyPDF) version 9.7 or higher

### Installation

Download the latest release from the [release overview](https://github.com/d-lopes/dmsplus/releases) and unzip or untar it on the server you want to run the application. The unzipped folder contains the directories `laravel` and `scanner`. Carry out the following steps in order to install the application:

1. install composer - on linux based machines you can simply run this command:&#x20;

```
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
```

1. Copy the `laravel` directory to the webserver's root directory (usually `/var/www/html`). In the remaining bits of this wiki this location is referred to as `LARAVEL_HOME`.
2. Run the command `composer install` in the `LARAVEL_HOME` directory.
3. Copy the `scanner` directory to a directory of your choice. In the remaining bits of this wiki this location is referred to as `SCANNER_HOME`.
4. create the following sub directories in the `LARAVEL_HOME` directory:
5. `LARAVEL_HOME/storage/logs`
6. `LARAVEL_HOME/storage/search`
7. `LARAVEL_HOME/storage/app/documents`
8. create a symbolic link from `LARAVEL_HOME/public/files` to /var/www/storage/app/documents

### Configuration

The following steps need to be carried out (in order) to configure the application appropriately: 1. Create a new user for a new database on your mysql server 2. Take over the settings from the `LARAVEL_HOME/config/php/local.ini` into the php configuration file of your web server 3. Configure a virtual host for port `9000` on your web server pointing to the `LARAVEL_HOME` directory 4. Set the following environment variables in your `.profile` file according to the settings made in steps 1 and 2:

* `WEB_HOST` (e. g. `localhost:9000`)
* `DB_HOST` (e. g. `localhost`)
* `MYSQL_DATABASE` (e. g. `myDatabase`)
* `MYSQL_USER` (e. g. `dmsAdmin`)
* `MYSQL_PASSWORD` (e. g. `aHard2GuessPwd`)
* Generate a Laravel application key with `php artisan generate:key`
* Populate the database by running `php artisan migrate` and `php artisan db:seed` in the `LARAVEL_HOME` directory
* Setup a cronjob that runs the shell script `watch.sh` in `SCANNER_HOME` directory periodically (e. g. every hour)

### Startup

Simply startup your web server. Please continue with the section [Smoketest](#smoketest) in order to continue.

## Smoketest

When you open the **dms+** web application via <http://localhost:9000> you should see the following landing page:

![landing page](https://raw.githubusercontent.com/d-lopes/dmsplus/master/docu/img/screenshots/landing-page.png)

Please refer to the [User Guide](https://github.com/d-lopes/dmsplus/wiki/User-Guide) for further information on how to navigate the application.
