> For the complete documentation index, see [llms.txt](https://za.docs.rechtlogisch.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://za.docs.rechtlogisch.de/beta/setup/install.md).

# Install

## Requirements

### [AWS Instance](https://aws.amazon.com/de/ec2/instance-types/t3/)

#### Instance type when DB on separate instance

t3.micro - 2 vCPU, 1 GiB RAM

#### Instance type when DB on same instance

t3.medium - 2 vCPU, 4 GiB RAM

#### Storage

At least 30 GB

### Software

Windows Server 2022 Datacenter (version 21H2)

#### Required

* [x] [XAMPP](https://www.apachefriends.org/index.html)
* [x] [VC++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170)
* [x] [git](https://git-scm.com/download/win)
* [x] [Composer](https://getcomposer.org/doc/00-intro.md#installation-windows)

#### Optional

* [ ] [Google Chrome](https://www.google.com/intl/en/chrome/)
* [ ] [TablePlus](https://tableplus.com/download)
* [ ] [VS Code](https://code.visualstudio.com/)
* [ ] [Adobe Reader](https://www.adobe.com/de/acrobat/pdf-reader.html)
* [ ] [7-Zip](https://7-zip.de/index.html)
* [ ] [Certbot](https://certbot.eff.org/instructions?ws=apache\&os=windows)

#### Versions

{% hint style="info" %}
As of 2024-03-07
{% endhint %}

[XAMPP with PHP 8.2](https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/8.2.12/xampp-portable-windows-x64-8.2.12-0-VS16-installer.exe/download) (64-bit)

[VC++ Redist 14](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) (64-bit)

[Composer 2.7](https://getcomposer.org/download/)

## Setup

#### Clone git repository&#x20;

```bash
git clone --single-branch https://gitlab.com/rechtlogischshared/za/weric.git C:\weric
```

Recommended target path: `C:\weric`

{% hint style="info" %}
Username and Personal Access Token required
{% endhint %}

#### Set DocumentRoot, Directory and comment out default port Listen and ServerName

Inside `C:\xampp\apache\conf\httpd.conf` change path to `C:/weric/api/public`

{% code title=" C:\xampp\apache\conf\httpd.conf" %}

```
DocumentRoot "C:/weric/api/public"
<Directory "C:/weric/api/public">
```

{% endcode %}

#### Enable FFI module for PHP&#x20;

Uncomment:

{% code title="C:\xampp\php\php.ini" %}

```ini
extension=ffi
```

{% endcode %}

and set:

{% code title="C:\xampp\php\php.ini" %}

```ini
ffi.enable=true
```

{% endcode %}

#### Edit PATH

Search for `Edit the system environment variables` and add `C:\weric\api\public\libs\windows` to user environment variables (cf. screenshot)

<figure><img src="https://1132661469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1JwLERtZ0izJ1T8Zmg4%2Fuploads%2FnxRafjLtfPJXyDh0XRXv%2Fedit-windows-environment-variables.png?alt=media&amp;token=1d5d48fd-7c37-4389-8cdd-f1d79f105bfe" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Requires to restart dependent services and UI applications so the newly set PATH is utilized by applications.
{% endhint %}

#### Copy .env.example

Create `.env` based on `.env.example` inside `C:\weric\api\` and adjust following variables:

{% code title="C:\weric\api.env" %}

```ini
API_TOKEN=YOUR_API_TOKEN
APP_ENV=development # change to "production" when going productive
APP_URL=https://your.host
CERTIFICATE_FILE="your.pfx" # set to "dvccsap11002.dll" for DATEV stick or comment out to use "test-softorg-pse.pfx"
DB_HOST=HOST
DB_PASSWORD="PASSWORD"
```

{% endcode %}

#### Install dependencies

```bash
cd C:\weric\api
composer install
```

#### Initialize database structure

```bash
cd C:\weric\api
php artisan migrate --seed
```

#### Disable virus Real-time protection or exclude following folders

```bash
C:\xampp\
C:\weric\api\
```

#### (Optional: SSL certificate)

Install [Certbot](https://certbot.eff.org/instructions?ws=apache\&os=windows) and run commands mentioned there.

Allow traffic on port 80 in AWS Console and in Windows Firewall.

Allow traffic on port 443 in AWS Console and in Windows Firewall.

Edit `C:\xampp\apache\conf\extra\httpd-ssl.conf`

{% code title="C:\xampp\apache\conf\extra\httpd-ssl.conf" %}

```
DocumentRoot "C:/weric/api/public"
ServerName host.domain
ServerAdmin admin@host.domain

SSLCertificateFile "C:\Certbot\live\host.domain\fullchain.pem"
SSLCertificateKeyFile "C:\Certbot\live\host.domain\privkey.pem"
```

{% endcode %}

Inside `C:\xampp\apache\conf\httpd.conf` you should disable default Port 80 (in case occupied Certbot can't renew certificates) and change ServerName

{% code title=" C:\xampp\apache\conf\httpd.conf" %}

```
#Listen 80
ServerName host.domain
```

{% endcode %}

[Test automatic renewal](https://certbot.eff.org/instructions?ws=apache\&os=windows#:~:text=by%20the%20webserver.-,Test%20automatic%20renewal,-The%20Certbot%20installation).

Setup task scheduler for automatic renewal (with pre- and post-hook).

#### (Optional: Run as service)

Add `C:\weric\api\public\libs\windows` to system environment variables.

Edit `C:\xampp\xampp-control.ini` to enable services:

{% code title="C:\xampp\xampp-control.ini" %}

```
[EnableServices]
Apache=1
MySQL=1 # if database on the same host
```

{% endcode %}

Start XAMPP Control Panel and click box left to Apache and MySQL to install services.

Disable autostart options in XAMPP Control Panel.

#### (Optional: Enable PHP OPcache)

Increases performance ([cf. PHP documentation](https://www.php.net/manual/en/intro.opcache.php)).

Edit `C:\xampp\php\php.ini` and uncomment:

{% code title="C:\xampp\php\php.ini" %}

```ini
zend_extension=opcache
```

{% endcode %}

Restart Apache service.
