---
description: "Installing FbExpert on Windows and Linux: Firebird kits, HTTPS, certificate, service and first administrator."
---

# Installation

FbExpert is deployed as a self-contained application. The packages contain the application, the tools and the Firebird kits it needs.

::: tip Versions
The current Windows package is supplied as a `.7z` file together with an `install-fbexpert-windows.ps1` script. The Linux archive is deployed with execute permissions and then a systemd service.
:::

## Prerequisites

| Item | Windows | Linux |
|---|---|---|
| System | Windows 10/11 or a recent Server | Linux x64 |
| Runtime | included in the self-contained package | included in the self-contained package |
| Ports | 7036 HTTPS, 5114 HTTP | 7036 HTTPS, 5114 HTTP or reverse proxy |
| Privileges | administrator for the service | root or sudo |
| Kits | 2.5 to 6.0 depending on the databases | 2.5 to 6.0 depending on the databases |

::: warning Windows 7
Windows 7 is not a supported target: the application targets .NET 10.
:::

## Windows

In an administrator PowerShell:

```powershell
E:\install-fbexpert-windows.ps1 `
  -Archive E:\FbExpert-7.477-win-x64.7z `
  -Upgrade `
  -InstallDir E:\FbExpert `
  -DataDir E:\ProgramData\FbExpert `
  -Kits '2.5,3.0,4.0,5.0,6.0' `
  -TrustCertificate `
  -AdminUser admin `
  -TrustedProxy 11.5.0.146 `
  -CookiePolicy same-as-request
```

::: warning PowerShell syntax
On Windows, parameters use `-Name` (single dash). The Linux options `--bind`, `--trusted-proxy`, `--cookie-policy` are **not** recognised: PowerShell treats them as positional arguments and fails on `-Port`.
:::

### What the script does

1. stops the service and any remaining FbExpert processes;
2. installs or updates the binaries;
3. installs the requested Firebird kits;
4. checks kit 5.0 and rebuilds the embedded runtime if necessary;
5. creates the first administrator if `-AdminUser` is supplied;
6. configures NSSM, permissions and the firewall;
7. starts HTTPS on `7036` and redirects HTTP `5114`;
8. installs the root certificate if `-TrustCertificate` is present;
9. waits for `/health/ready`.

### Expected result

```text
https://localhost:7036/login
```

### Useful options

| Option | Purpose |
|---|---|
| `-InstallDir` | folder for the binaries |
| `-DataDir` | data, databases, backups, logs |
| `-Kits` | Firebird versions to install |
| `-TrustCertificate` | imports the FbExpert root into `LocalMachine\Root` |
| `-AdminUser` | creates the first administrator account |
| `-TrustedProxy` | trusted proxy address(es) for `X-Forwarded-*`, comma-separated |
| `-CookiePolicy` | `always` (default, direct HTTPS) or `same-as-request` (HTTP proxy) |
| `-Bind` | listen address in `-HttpOnly` mode (default `0.0.0.0`) |
| `-NssmPath` | uses a local `nssm.exe` if the download fails |
| `-HttpOnly` | forces HTTP; the secure cookie may cause a login loop |

## Linux

```bash
sudo mkdir -p /opt/fbexpert
sudo 7z x FbExpert-7.449-linux-x64.7z -o/opt/fbexpert
sudo chmod +x /opt/fbexpert/FbExpert.Blazor /opt/fbexpert/tools/fetch-kits.sh
sudo /opt/fbexpert/FbExpert.Blazor --urls http://127.0.0.1:5114
```

If `7z` is not installed: `sudo dnf install p7zip` or `sudo apt install p7zip-full`.

Fedora 45: same procedure. SELinux runs in `enforcing` mode by default; the installer applies `restorecon` and `semanage`. Packages are installed with `dnf`.

::: warning SELinux and `203/EXEC`
If the service fails with `Permission denied` on `/opt/fbexpert/FbExpert.Blazor` even though the file is executable, the SELinux context is the cause. The installer now applies `restorecon` and labels the binary as `bin_t`. Manual check:

```bash
sudo restorecon -RF /opt/fbexpert
sudo semanage fcontext -a -t bin_t /opt/fbexpert/FbExpert.Blazor
sudo restorecon -v /opt/fbexpert/FbExpert.Blazor
```
:::

For Rocky Linux 8 / RHEL 8, the `tools/install-fbexpert-linux.sh` script installs the service account, systemd and nginx.

## Verification

```powershell
Invoke-WebRequest http://localhost:5114/health/ready -UseBasicParsing
```

Expected: `200`.

If you get `503`, check:

```text
http://localhost:5114/startup-error
```

## First login

1. open `https://localhost:7036/login`;
2. log in with the administrator account;
3. check that the databases appear in the registry;
4. configure the users and access profiles.

## First administrator via `/setup`

If no account was created by the installer:

```text
https://<server>:7036/setup
```

The page can be reached from any workstation as long as no user exists. The account created receives the `ADMIN` role (super administrator), then the page closes and redirects to `/login`.

::: warning
Create the first account immediately after installation: while `/setup` is open, anyone who reaches the URL can do it.
:::

## HTTPS proxy on another machine

The authentication cookie is marked `Secure`: the session can only be kept over HTTPS. If nginx terminates TLS on another machine, declare its address so that `X-Forwarded-Proto` and `X-Forwarded-For` are taken into account:

```bash
sudo bash ./tools/install-fbexpert-linux.sh \
  --archive ./FbExpert-<version>-linux-x64.7z \
  --skip-nginx \
  --bind 10.0.0.12 \
  --trusted-proxy 10.0.0.5 \
  --public-url https://demo.fbexpert.tetrasys.be \
  --upgrade
```

Without `--trusted-proxy`, only `127.0.0.1` is trusted: the application believes it is serving HTTP, refuses the session and the real client IP is lost (IP blocking and audit become inaccurate). The `/login?error=tls` message flags this case since 7.457.

## Direct LAN access (without a TLS proxy)

To administer a machine on the local network without going through the public proxy, Kestrel can listen on the private IP over HTTP (`http://11.5.0.8:5114`). The installer detects the absence of local TLS and applies `Security__CookieSecurePolicy=SameAsRequest`: the session cookie is only marked `Secure` if the request arrives over HTTPS. Without that, the browser would never send the cookie back over HTTP and `/login` would loop.

```bash
sudo bash ./tools/install-fbexpert-linux.sh \
  --archive ./FbExpert-<version>-linux-x64.7z \
  --skip-nginx --skip-firewall \
  --bind 11.5.0.8 \
  --public-url http://11.5.0.8:5114 \
  --upgrade
```

- Mode suited to a trusted network: the session travels in clear text over the LAN.
- The same instance can receive public traffic over HTTPS through a remote proxy: add `--trusted-proxy <nginx-ip>`; HTTPS requests then receive a `Secure` cookie, while direct HTTP requests receive a plain cookie.
- To harden things further, serve TLS locally (`nginx` + `--tls-cert`) and force `--cookie-policy always`.

## Public demonstration

On Linux, the installer applies the whole configuration:

```bash
sudo bash /opt/fbexpert/tools/install-fbexpert-linux.sh \
  --archive ./FbExpert-<version>-linux-x64.7z \
  --demo --demo-user demo \
  --upgrade
```

- `--demo`: demonstration mode, IP-based lockout only (3 failures / 10 min, 60-minute block), administrator writes refused (`--demo-allow-writes` to allow them).
- Public credentials: `/etc/fbexpert/demo.env` in `0600`, never in `appsettings.json` or in the repository.
- The public account is **created, or its password aligned**, by the installer (`--set-user`): the login panel only displays it. Manually: `FbExpert.Blazor --set-user demo --role ADMIN`.
- nginx rate limiting on `/auth/login`: built into the local configuration, or deployed as two fragments (`nginx-demo-zone.conf` for the `http` context, `nginx-demo-login.conf` for the `server` block) when the proxy is remote.
- Reset: VM snapshot every 2 h on the hypervisor side.

## Login refused despite a correct password

```bash
sudo systemctl stop fbexpert
cd /opt/fbexpert
sudo runuser -u fbexpert -- \
  env HOME=/var/lib/fbexpert XDG_DATA_HOME=/var/lib/fbexpert/.local/share \
  /opt/fbexpert/FbExpert.Blazor --check-password admin
sudo systemctl start fbexpert
```

The command shows the system database actually opened, the account status, the result of the hash verification and the latest audit events: it distinguishes a different password from a transport or proxy problem.

## Check the installed version

```bash
/opt/fbexpert/FbExpert.Blazor --version
```

This command reads the version compiled into the binary, independently of a manually copied `VERSION.txt`. Since 7.459, the installer reads the `VERSION.txt` from the archive, displays `Mise à jour X → Y`, refuses an archive older than the installed version (`--allow-downgrade` to force it) and checks the binary version after copying.

To identify an archive:

```bash
for f in /root/FbExpert-*-linux-x64.7z; do
    printf '%s : ' "$f"
    7z e -so "$f" VERSION.txt | head -n1
done
```

## System database backup

The embedded engine only opens the database in a single process: `gbak` cannot read it while the service is running (error `Database already opened with engine instance`).

- At startup, **before** the database is opened, a backup is created if the system schema has changed (pre-migration) or if no recent `.fbk` exists.
- On demand, with the service stopped: `FbExpert.Blazor --backup-system`.
- Files produced outside a session are imported into the catalog and encrypted at the next startup.

```bash
sudo systemctl stop fbexpert
cd /opt/fbexpert
sudo runuser -u fbexpert -- \
  env HOME=/var/lib/fbexpert XDG_DATA_HOME=/var/lib/fbexpert/.local/share \
  /opt/fbexpert/FbExpert.Blazor --backup-system
sudo systemctl start fbexpert
```

::: tip Console alternative
On Linux, `create-admin-linux.sh` creates the account without a browser. If password entry fails or the account already exists:

```bash
sudo bash /opt/fbexpert/tools/create-admin-linux.sh --user admin --reset
```
:::

::: tip Certificate
The server certificate is signed by a local root, `FbExpert Root CA`. The file to install on workstations is the root, not the server certificate.
:::
