> For the complete documentation index, see [llms.txt](https://ispectra.gitbook.io/mutamad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ispectra.gitbook.io/mutamad/getting-started/production.md). Agents can also search and read this documentation through its [MCP server](https://ispectra.gitbook.io/mutamad/~gitbook/mcp).

# Production

Everything to set before a Mutamad site faces the public.

{% hint style="danger" %}
Do these before the site faces the public. Several of them fail **silently**: the site works, and a control is simply not there.
{% endhint %}

## Checklist

| #  | Set                                                    | Why                                                                                                                                                        |
| -- | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1  | `trusted_host_patterns`                                | Without it Drupal answers to any `Host` header, which makes password-reset poisoning trivial (ECC 2-15).                                                   |
| 2  | The hash salt, read from a file outside the repository | A salt in the code base is a salt anyone with the code has.                                                                                                |
| 3  | Read-only configuration                                | Configuration changes come through deployment, not the live site.                                                                                          |
| 4  | `MUTAMAD_MAILER_DSN`                                   | Without a mail relay, notifications and password resets are lost without an error.                                                                         |
| 5  | Cron every minute                                      | Automated Cron is off; without the server's cron, security checks, password expiry and log trimming stop.                                                  |
| 6  | Syslog forwarding to the SIEM                          | Logs go to syslog `LOCAL0`; something must forward them (ECC 2-12-3-3).                                                                                    |
| 7  | Static-file caching on nginx                           | Apache needs nothing.                                                                                                                                      |
| 8  | The Digital Stamp                                      | Until set, the stamp says the site is a demo. See [After installation](https://ispectra.gitbook.io/mutamad/getting-started/after-installation.md), step 2. |
| 9  | The `security.txt` contact                             | Researchers look for it at `/.well-known/security.txt`.                                                                                                    |
| 10 | Back up the key files separately from the database     | A backup that holds both the data and its key protects neither.                                                                                            |
| 11 | Turn development tools off                             | Storybook runs under DDEV only; `mutamad-verify` flags it if it is on.                                                                                     |
| 12 | Run `mutamad-verify`                                   | Every control holds on *this* server, not only on the developer's.                                                                                         |

## Settings

Mutamad's hardened settings are in `web/sites/default/settings.mutamad.php`, loaded by `settings.php`. Put the server's own values in `settings.local.php`:

```php
<?php

$databases['default']['default'] = [
  'driver' => 'mysql',
  'database' => 'mutamad',
  'username' => 'mutamad',
  'password' => '…',
  'host' => 'localhost',
  'port' => '3306',
  'prefix' => '',
  'collation' => 'utf8mb4_unicode_ci',
];

// The salt from a file outside the site.
$settings['hash_salt'] = trim(file_get_contents('/etc/mutamad/hash_salt'));

// ECC 2-15: answer only to this site's own address.
$settings['trusted_host_patterns'] = [
  '^www\.example\.gov\.sa$',
];
```

Create the salt file:

```bash
mkdir -p /etc/mutamad
openssl rand -base64 64 | tr -d '\n' > /etc/mutamad/hash_salt
chown root:www-data /etc/mutamad/hash_salt && chmod 640 /etc/mutamad/hash_salt
```

## Email

Set the relay in the web server's environment, for example in the PHP-FPM pool:

```ini
env[MUTAMAD_MAILER_DSN] = smtp://user:password@relay.example.gov.sa:587
```

The site's email address (**Configuration → Basic site settings**) must be on the entity's domain, covered by its SPF, DKIM and DMARC records. Emails are sent in the recipient's preferred language.

## Cron

In the crontab of the user that owns the site:

```cron
* * * * * cd /var/www/example.gov.sa && vendor/bin/drush cron --quiet
```

Each task is its own Ultimate Cron job, run every 15 minutes at its own minute. The status report warns after an hour without cron. DDEV runs cron already (`.ddev/config.cron.yaml`).

## Logging to the SIEM

Every log entry goes to the database log and to syslog as one JSON line: message, level, channel, time, user, IP address and URL. Facility `LOCAL0`, ident `mutamad`. Forward it with rsyslog, for example `/etc/rsyslog.d/30-mutamad.conf`:

```
local0.*  @@siem.example.gov.sa:514
```

The SIEM's copy is the record and the auditor's export: clearing the database log does not touch it. The database log keeps 100,000 entries; export it with `drush watchdog:show --format=csv`.

## nginx: cache static files

Drupal's `.htaccess` does this on Apache. On nginx, in the site's `server` block:

```nginx
location ~* \.(css|js|woff2?|ttf|otf|eot|jpe?g|gif|png|webp|svg|ico)$ {
    try_files $uri @rewrite;
    expires max;
    log_not_found off;
}
```

Without it, the theme's font (IBM Plex Sans Arabic) is checked again on every page.

## security.txt

`/.well-known/security.txt` (RFC 9116) names whom to tell about a vulnerability, with `Preferred-Languages: ar, en`. The contact is the site's email unless the security recipe was applied with another. `Expires` is set a year after installation; `mutamad-verify` warns 30 days before it passes. Update it at **Configuration → System → Security.txt**.

## Server layout

<figure><img src="https://171036656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQSekKpxOCXC1q6G2NRy9%2Fuploads%2Fgit-blob-67ad61755ebba02bc13e575ce6231cf7e3c57b74%2Fdiagram-deployment.svg?alt=media" alt="Reference deployment: visitors and staff through a WAF to the application tier, a data tier on the internal network, and the SIEM, mail relay and optional model server"><figcaption><p>A reference deployment. The entity hosts it; Mutamad makes no call outside it except those listed on this page.</p></figcaption></figure>

A typical layout on Apache with PHP-FPM:

* a Linux user of its own for the site, and a PHP 8.4 FPM pool running as that user
* `/var/www/example.gov.sa/` holding the project: `web/` as the document root, `private-files/` and `vendor/` beside it
* the virtual host pointing at `web/`, HTTPS only

```
/var/www/example.gov.sa/
├── composer.json
├── private-files/        ← outside the web root (ECC 2-7-2)
│   └── mutamad-keys/     ← the MFA key: back up with secrets, not the database
├── vendor/
└── web/                  ← DocumentRoot
```

## Updating a site

```bash
composer update "drupal/mutamad*" --with-all-dependencies
vendor/bin/drush updatedb --yes
vendor/bin/drush cache:rebuild
bash .ddev/commands/web/mutamad-verify
```

Read each project's changelog before updating. Composer applies every patch in `patches/` and stops if one no longer applies.

## Backups

Backups, off-site storage and restore drills are the hosting entity's. Back up the database, `web/sites/default/files/` and `private-files/`, and keep the key files in `private-files/mutamad-keys/` with the site's secrets, separately.

{% hint style="warning" %}
**Never replace an existing key file.** Everything encrypted with it becomes unreadable; every user enrolled in MFA is locked out.
{% endhint %}
