<a id="install"></a>

# 導入方法

## Weblate のインストール

セットアップと経験に応じて、適切なインストール方法を選択する:

* [Docker を使用したインストール](https://docs.weblate.org/ja/latest/admin/install/docker.md)、運用環境として推奨。
* Virtualenv のインストール、推奨する運用環境:
  * [Debian と Ubuntu にインストール](https://docs.weblate.org/ja/latest/admin/install/venv-debian.md)
  * [SUSE および openSUSE にインストール](https://docs.weblate.org/ja/latest/admin/install/venv-suse.md)
  * [RedHat、Fedora、CentOS にインストール](https://docs.weblate.org/ja/latest/admin/install/venv-redhat.md)
  * [macOS にインストール](https://docs.weblate.org/ja/latest/admin/install/venv-macos.md)
* [ソースからインストール](https://docs.weblate.org/ja/latest/admin/install/source.md)、開発環境として推奨。
* [OpenShift へのインストール](https://docs.weblate.org/ja/latest/admin/install/openshift.md)
* [Kubernetes へのインストール](https://docs.weblate.org/ja/latest/admin/install/kubernetes.md)

<a id="architecture"></a>

## アーキテクチャの概要

Web サーバー
: 受信 HTTP リクエストの処理、[静的ファイルの提供](#static-files)。

Celery ワーカー
: [Celery を使用するバックグラウンド タスク](#celery) は、ここで実行されます。
  <br/>
  作業負荷に応じて、ワーカー数を変更してください。
  <br/>
  Weblate を水平方向にスケーリングする場合は、専用ノードを使用してください。

Application server
: A WSGI or ASGI server serving web pages to users.
  <br/>
  Weblate を水平方向にスケーリングする場合は、専用ノードを使用してください。

データベース
: すべてのコンテンツを保存するための PostgreSQL データベース サーバー。参照: [Weblate のデータベース設定](#database-setup)。
  <br/>
  数百億の単語をホストするサイトの場合、専用のデータベース ノードを使用してください。

データストア
: キャッシュとタスク キュー用の Valkey または Redis のようなキー・バリュー型データストア。参照: [Celery を使用するバックグラウンド タスク](#celery)。
  <br/>
  Weblate を水平方向にスケーリングする場合は、専用ノードを使用してください。

ファイルシステム
: ファイルシステム ストレージ は、VCS リポジトリとアップロードされたユーザーデータを保存するための領域です。これは、すべてのプロセスで共有されます。
  <br/>
  Weblate を水平方向にスケーリングする場合は、ネットワーク ストレージを使用してください。

メールサーバー
: メール送信用の SMTP サーバー。参照: [メール送信の設定](#out-mail)。外部から提供できます。

#### HINT
[Docker を使用したインストール](https://docs.weblate.org/ja/latest/admin/install/docker.md) には PostgreSQL と Valkey が含まれているため、インストールが簡単になります。

<a id="requirements"></a>

## ソフトウェア要件

### オペレーティング システム

Weblate は、Linux、FreeBSD、macOS で動作することが判明しています。他の Unix のようなシステムでも動作する可能性は高いでしょう。

Weblate は Windows には対応していません。しかし、動作するかもしれないのでパッチは歓迎します。

#### SEE ALSO
[アーキテクチャの概要](#architecture) では、Weblate の全体的なアーキテクチャと必要なサービスについて解説しています。

<a id="python-deps"></a>

### Python の依存関係

Weblateは、[Python](https://www.python.org/) で書かれており、Python 3.12 以降に対応しています。依存関係は、pip を使ってのインストールすることも、ディストリビューションのパッケージからもインストールできます。`requirements.txt` は、依存関係の完全なリストです。

最も注目すべき依存関係:

Django
: [https://www.djangoproject.com/](https://www.djangoproject.com/)

Celery
: [https://docs.celeryq.dev/](https://docs.celeryq.dev/)

Translate Toolkit
: [https://toolkit.translatehouse.org/](https://toolkit.translatehouse.org/)

translation-finder
: [https://github.com/WeblateOrg/translation-finder](https://github.com/WeblateOrg/translation-finder)

Python Social Auth
: [https://python-social-auth.readthedocs.io/](https://python-social-auth.readthedocs.io/)

Django REST フレームワーク
: [https://www.django-rest-framework.org/](https://www.django-rest-framework.org/)

<!-- Table is generated using scripts/show-extras.py -->

#### オプションの依存関係

| オプションの依存関係指定子   | Python パッケージ                                                                                                                                                              | Weblate の機能                                                                                                        |
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| `amazon`        | [boto3](https://pypi.org/project/boto3/)<br/><br/><br/>[django-ses](https://pypi.org/project/django-ses/)<br/><br/>                                                       | [Amazon Translate](https://docs.weblate.org/ja/latest/admin/machine.md#mt-aws), AWS SES e-mail backend                     |
| `asgi`          | [granian](https://pypi.org/project/granian/)<br/><br/>                                                                                                                    | ASGI server for Weblate                                                                                            |
| `gelf`          | [logging-gelf](https://pypi.org/project/logging-gelf/)<br/><br/>                                                                                                          | [Graylog によるログ管理](#graylog)                                                     |
| `gerrit`        | [git-review](https://pypi.org/project/git-review/)<br/><br/>                                                                                                              | [Gerrit review requests](https://docs.weblate.org/ja/latest/admin/code-hosting.md#code-hosting-gerrit)                          |
| `google`        | [google-cloud-storage](https://pypi.org/project/google-cloud-storage/)<br/><br/><br/>[google-cloud-translate](https://pypi.org/project/google-cloud-translate/)<br/><br/> | 用語集対応の [Google Cloud Translation Advanced](https://docs.weblate.org/ja/latest/admin/machine.md#mt-google-translate-api-v3) |
| `google-errors` | [google-cloud-error-reporting](https://pypi.org/project/google-cloud-error-reporting/)<br/><br/>                                                                          | [エラーレポートの収集とパフォーマンスの監視](#collecting-errors)                                               |
| `ldap`          | [django-auth-ldap](https://pypi.org/project/django-auth-ldap/)<br/><br/>                                                                                                  | [LDAP 認証](https://docs.weblate.org/ja/latest/admin/auth.md#ldap-auth)                                                   |
| `mercurial`     | [mercurial](https://pypi.org/project/mercurial/)<br/><br/>                                                                                                                | [Mercurial](https://docs.weblate.org/ja/latest/vcs.md#vcs-mercurial)                                             |
| `postgres`      | [psycopg](https://pypi.org/project/psycopg/)<br/><br/>                                                                                                                    | PostgreSQL（参照: [Weblate のデータベース設定](#database-setup)）                                   |
| `rollbar`       | [rollbar](https://pypi.org/project/rollbar/)<br/><br/>                                                                                                                    | [エラーレポートの収集とパフォーマンスの監視](#collecting-errors)                                               |
| `saml`          | [python3-saml](https://pypi.org/project/python3-saml/)<br/><br/><br/>[xmlsec](https://pypi.org/project/xmlsec/)<br/><br/>                                                 | [SAML 認証](https://docs.weblate.org/ja/latest/admin/auth.md#saml-auth)                                                   |
| `saml2idp`      | [djangosaml2idp2](https://pypi.org/project/djangosaml2idp2/)<br/><br/>                                                                                                    | SAML 2 IDP を Weblate に統合                                                                                           |
| `sphinx`        | [Sphinx](https://pypi.org/project/Sphinx/)<br/><br/>                                                                                                                      | [POT ファイルの更新（Sphinx）](https://docs.weblate.org/ja/latest/admin/addons.md#addon-weblate-gettext-sphinx) が必要                |
| `wllegal`       | [wllegal](https://pypi.org/project/wllegal/)<br/><br/>                                                                                                                    | Hosted Weblate との統合                                                                                                |
| `wsgi`          | [granian](https://pypi.org/project/granian/)<br/><br/>                                                                                                                    | WSGI server for Weblate                                                                                            |
| `zxcvbn`        | [django-zxcvbn-password-validator](https://pypi.org/project/django-zxcvbn-password-validator/)<br/><br/>                                                                  | [パスワード認証](https://docs.weblate.org/ja/latest/admin/auth.md#password-authentication)                                     |

pip を使用してインストールする場合には、特定の機能を選択してインストールできます。インストール時の指定方法:

```sh
uv pip install "weblate[Postgres,Amazon,SAML]"
```

または、すべてのオプション機能を追加して Weblate をインストールする方法:

```sh
uv pip install "weblate[all]"
```

もしくは、どのようなオプション機能も追加せずに Weblate をインストールする方法:

```sh
uv pip install weblate
```

<a id="troubleshoot-pip-install"></a>

### pip install のトラブルシューティング

`ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)`
: これは、PyPI を介して配布されるバイナリ パッケージとディストリビューションとの互換性がないことが原因です。これに対処するために必要な、システムでのパッケージの再構築方法:
  <br/>
  ```sh
  uv pip install --force-reinstall --no-binary :all: cffi
  ```

`error: ‘xmlSecKeyDataFormatEngine’ undeclared (first use in this function); did you mean ‘xmlSecKeyDataFormat’?`
: これは xmlsec パッケージの既知の問題です。参照: [https://github.com/xmlsec/python-xmlsec/issues/314](https://github.com/xmlsec/python-xmlsec/issues/314)。

`lxml & xmlsec libxml2 library version mismatch`
: `lxml` および `xmlsec` パッケージは、単一の `libxml2` に対してビルドされる必要があります。この問題を回避するには、それらをローカルでビルドしてください:
  <br/>
  ```sh
  uv pip install --force-reinstall --no-binary xmlsec --no-binary lxml lxml xmlsec
  ```

### その他のシステム要件

システムにインストールされていることが必要な依存関係:

`Git`
: [https://git-scm.com/](https://git-scm.com/)

`git-review` （Gerrit 対応用のオプション）
: [git-review](https://pypi.org/project/git-review/)

`git-svn` （Subversion 対応用のオプション）
: [https://git-scm.com/docs/git-svn](https://git-scm.com/docs/git-svn)

`tesseract` （システムで **tesserocr** バイナリ ホイールが利用できない場合にのみ必要）
: [https://github.com/tesseract-ocr/tesseract](https://github.com/tesseract-ocr/tesseract)

### ビルド時の依存関係

[Python の依存関係](#python-deps) の一部をビルドするには、依存関係のインストールが必要となることがあります。これは、インストールの方法により異るので、個別のパッケージについてのドキュメントを確認してください。 しかし、`pip` を使用してインストールする場合、ビルド済みの `Wheels` を使用する場合、または配布パッケージを使用する場合には必要ありません。

<a id="hardware"></a>

## ハードウェア要件

Weblate は、最新のハードウェアであれば問題なく動作します。以下は、Weblate を単一のホスト（Weblate、データベース、Web サーバー）で動作させるために必要な最小限の構成:

* 3 GB の RAM
* 2 CPU コア
* 1 GB の記憶容量（HDD or SSD）

#### NOTE
実際に必要な Weblate のインストールの要件は、Weblate で管理する翻訳のサイズによって大きく変化します。

### メモリ使用量

メモリは多ければ多いほど良い - すべてのレベル（ファイルシステム、データベース、Weblate）でキャッシュとして使用します。数百の翻訳コンポーネントの場合は、少なくとも 4 GB の RAM を推奨します。

#### HINT
メモリが推奨よりも少ないシステムの場合は、[シングルプロセス Celery の設定](#minimal-celery) を推奨します。

### CPU 使用率

同時使用者が多い場合、必要な CPU コアの数が増えます。

Weblate 2026.8 introduced NumPy as a required dependency. On x86-64 systems,
the optimized NumPy build bundled in the Docker image requires an x86-64-v2
compatible CPU. Without the required CPU features, NumPy fails to load and
Weblate cannot start.

Before upgrading, check for the required SSE4.2 CPU feature on the Linux system
running Docker:

```sh
grep sse4_2 /proc/cpuinfo
```

Empty output indicates that a required CPU feature is unavailable. This is a
preliminary check; finding SSE4.2 does not verify all x86-64-v2 CPU features.

If Docker runs in a virtual machine, run the check inside the guest. Virtual
machines can hide CPU features supported by the host. Configure the virtual
machine to expose the required host CPU features, then reboot the guest. If
the physical CPU lacks the required features, upgrade the hardware.

### ストレージ使用量

一般的なデータベース ストレージの使用量は、ホストサーバーで管理する 100 万語の単語につき約 300 MB 必要です。

リポジトリのクローンに必要なストレージ スペースはさまざまですが、Weblate は、シャロー クローンを実行してサイズを最小限に抑える努力をします。

### Storage performance

Version control operations perform many filesystem metadata lookups. The
`vcs` subdirectory in [`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) therefore needs low read
latency; storage with slow metadata access can make operations such as
**git status** take a long time even when its bulk throughput is good.
Keep [`CACHE_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CACHE_DIR) on low-latency local or temporary storage when
possible.

The deployment checks measure metadata lookup latency for both locations and
warn when the median latency exceeds 10 milliseconds. This is an approximate
point-in-time measurement affected by filesystem and system load. Rerun
**weblate check --deploy** before changing the storage configuration.

### ノード数

小規模から中規模のサイト（ホストされた単語数が数百万）の場合、Weblate のすべてのコンポーネント（参照: [アーキテクチャの概要](#architecture)）を単一ノードで実行できます。

数億件の翻訳対象語を扱う規模に成長する場合は、専用のデータベース ノードを用意することを推奨します（参照: [Weblate のデータベース設定](#database-setup)）。

## Verifying release artifacts

Release archives can be verified using the signatures, attestations, and SBOMs
published with GitHub release assets. See [Verifying release artifacts](https://docs.weblate.org/ja/latest/security/release-artifacts.md#verify).

<a id="file-permissions"></a>

## ファイル システムのアクセス権

Weblate プロセスは、データを保持するディレクトリ ([`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) ) に対して、読み書き権限が必要です。このディレクトリ内のすべてのファイルは、すべての Weblat プロセス（通常は WSGI と Celery、参照: [実行サーバー](#server) および [Celery を使用するバックグラウンド タスク](#celery)）を実行しているユーザーが所有し、書き込み権限が必要です。

デフォルトの設定では、これらは Weblate のソースと同じ階層に配置されますが、`/var/lib/weblate` などへの、より適切な場所に移動させてください。

Weblate は、これらのディレクトリを自動的に作成しようとします。しかし、アクセス権がなければ作成できません。

The configured [`CACHE_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CACHE_DIR) also has to be writable by the Weblate
process and has to allow executing generated helper files. Do not mount
[`CACHE_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CACHE_DIR) with the `noexec` option.

また、[管理コマンド](https://docs.weblate.org/ja/latest/admin/management.md#manage) の実行には注意が必要です。これは、Weblate 自体の実行と同じユーザーで実行することが必要なためです。実行できなければ、アクセス権の設定を間違えたファイルがあるということです。

Docker コンテナでは、`/app/data` ボリューム内のすべてのファイルは、コンテナ内の `weblate` ユーザーは所有者でなければなりません（UID 1000）。

#### SEE ALSO
[静的ファイルの提供](#static-files)

<a id="database-setup"></a>

## Weblate のデータベース設定

PostgreSQL データベース サーバーで Weblate を実行することを推奨します。

PostgreSQL 13 以降に対応しています。PostgreSQL 15 以降を推奨します。

#### SEE ALSO
* [強力なデータベース エンジンの使用](#production-database)
* [データベース](https://docs.djangoproject.com/ja/stable/ref/databases/)
* [他のデータベースから PostgreSQL に移行](https://docs.weblate.org/ja/latest/admin/upgrade.md#database-migration)

<a id="db-connections"></a>

### データベース接続

デフォルトの設定では、各 Weblate プロセスはデータベースへの永続的な接続を維持します。永続的な接続により、データベースサーバーに対するリソース使用量が増えることがあります。詳細については、[`CONN_MAX_AGE`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-CONN_MAX_AGE) と [持続的 (persistent) な接続](https://docs.djangoproject.com/ja/stable/ref/databases/#persistent-database-connections) を確認してください。

Weblate に必要な最小接続数:

* $(4 \times \mathit{nCPUs}) + 2$ （Celery プロセスの場合）
* $\mathit{nCPUs} + 1$ （WSGI ワーカーの場合）

これは、このドキュメントで提供されている Docker コンテナのデフォルトと設定例に当てはまりますが、WSGI ワーカーの量を変更したり、Celery の並列処理を調整したりすると、数値の変更が必要になります。

The actual limit for the number of database connections needs to be higher to
account for the following situations:

* [管理コマンド](https://docs.weblate.org/ja/latest/admin/management.md#manage) にも接続が必要です。
* If a process is killed (for example by OOM killer), it might block the existing connection until timeout.

#### SEE ALSO
[Celery を使用するバックグラウンド タスク](#celery)、[NGINX および uWSGI の設定例](#uwsgi)、[`WEBLATE_WORKERS`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_WORKERS)

<a id="postgresql"></a>

### PostgreSQL

通常、Django ベースのサイトには PostgreSQL が最適です。これは、Django データベース層の実装に使用する参照データベースです。

#### NOTE
Weblate では、場合によっては個別にインストールすることが必要なトライグラム拡張機能を使用します。`postgresql-contrib` または同様の名前のパッケージを探してください。

#### SEE ALSO
[PostgreSQL に関するノート](https://docs.djangoproject.com/ja/stable/ref/databases/#postgresql-notes)

<a id="dbsetup-postgres"></a>

#### PostgreSQL でデータベースの作成

通常は、Weblate を専用のデータベースと、専用のユーザーアカウントで実行してください。設定例:

```sh
# If PostgreSQL was not installed before, set the main password
sudo -u postgres psql postgres -c "\password postgres"

# Create a database user called "weblate"
sudo -u postgres createuser --superuser --pwprompt weblate

# Create the database "weblate" owned by "weblate"
sudo -u postgres createdb -E UTF8 -O weblate weblate
```

#### HINT
Weblate ユーザーを、PostgreSQL のスーパーユーザーにしたくない場合は、省略できます。その場合、Weblate が使用するスキーマの PostgreSQL スーパーユーザーとして、移行手順の一部を手動で実行することになります。実行する移行コマンド:

```postgres
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS btree_gin;
CREATE EXTENSION IF NOT EXISTS btree_gist;
```

<a id="config-postgresql"></a>

#### Weblate で PostgreSQL を使用するための設定

`settings.py` に必要な PostgreSQL 用の設定:

```python
DATABASES = {
    "default": {
        # Database engine
        "ENGINE": "django.db.backends.postgresql",
        # Database name
        "NAME": "weblate",
        # Database user
        "USER": "weblate",
        # Configures name of the PostgreSQL role to alter during the database migration
        # "ALTER_ROLE": "weblate",
        # Database password
        "PASSWORD": "password",
        # Set to empty string for localhost
        "HOST": "database.example.com",
        # Set to empty string for default
        "PORT": "",
        # Persistent connections
        "CONN_MAX_AGE": None,
        "CONN_HEALTH_CHECKS": True,
    }
}
```

データベースの移行時には、Weblate が使用するデータベースのロールに対して [ALTER ROLE](https://www.postgresql.org/docs/16/sql-alterrole.html) を実行します。ほとんどの場合、ロールの名前は username と一致します。より複雑な設定では、ロール名がユーザー名と異なり、データベース移行中に存在しないロールについてのエラーが発生します（`psycopg2.errors.UndefinedObject: role "weblate@hostname" does not exist`）。これは Azure Database for PostgreSQL で発生することは判明していますが、この環境に限定されていません。データベース移行時に、Weblate が変更することが必要なロール名を `ALTER_ROLE` に設定してください。

#### SEE ALSO
[データベース接続](#db-connections)

## その他の設定

<a id="out-mail"></a>

### メール送信の設定

Weblate は、さまざまなタイミングでメールを送信します。ー アカウントの有効化やユーザーが設定した通知など。そのためには、SMTP サーバーへの接続が必要となります。

メール サーバーの初期設定に使用する設定項目: [`EMAIL_HOST`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_HOST)、[`EMAIL_HOST_PASSWORD`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_HOST_PASSWORD)、[`EMAIL_USE_TLS`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_USE_TLS)、[`EMAIL_USE_SSL`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_USE_SSL)、[`EMAIL_HOST_USER`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_HOST_USER) および [`EMAIL_PORT`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_PORT)。 名前は明確ですが、詳細については Django の資料を確認してください。

#### HINT
対応していない認証方法でエラーが発生した場合（例: `SMTP AUTH extension not supported by server`）は、安全でない接続が原因でサーバーが認証を拒否している可能性が高いです。その場合は、[`EMAIL_USE_TLS`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_USE_TLS) を有効にしてみてください。

#### SEE ALSO
* [Weblate からメールが届かない](https://docs.weblate.org/ja/latest/contributing/debugging.md#debug-mails)
* [Docker コンテナでの送信メール設定](https://docs.weblate.org/ja/latest/admin/install/docker.md#docker-mail)

<a id="reverse-proxy"></a>

### リバース プロキシの背後で実行

Weblate のいくつかの機能は、正しい HTTP ヘッダーが Weblate に渡されることに依存します。リバースプロキシを使用する場合は、必要な情報が正しく渡されていることを確認してください。

この設定のデバッグには、[性能レポート](https://docs.weblate.org/ja/latest/admin/admin.md#manage-performance) 内の HTTP environment を確認してください。

クライアント IP アドレス
: これは [接続制限](https://docs.weblate.org/ja/latest/admin/optionals.md#rate-limit) または [監査ログ](https://docs.weblate.org/ja/latest/user/profile.md#audit-log) のために必要です。
  <br/>
  Weblate は、WSGI ハンドラによって設定される `REMOTE_ADDR` から IP アドレスを解析します。これは、空の場合（WSGI にソケットを使用時）や、リバースプロキシのアドレスを含む場合があるため、Weblate にはクライアント IP アドレスを含む追加の HTTP ヘッダーが必要です。
  <br/>
  [`IP_BEHIND_REVERSE_PROXY`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_BEHIND_REVERSE_PROXY) を有効にするだけで、ほとんどの一般的な構成では十分なはずですが、[`IP_PROXY_HEADER`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_PROXY_HEADER) および [`IP_PROXY_OFFSET`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_PROXY_OFFSET) も調整する必要があるかもしれません（Docker コンテナでは [`WEBLATE_IP_PROXY_HEADER`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_IP_PROXY_HEADER) と [`WEBLATE_IP_PROXY_OFFSET`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_IP_PROXY_OFFSET) を使用します）。
  <br/>
  The reverse proxy which connects to Weblate must overwrite the configured
  header or append a verified peer address at the position selected by
  [`IP_PROXY_OFFSET`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_PROXY_OFFSET). Do not select a client-supplied address, and do
  not expose the application server through a path which bypasses the trusted
  proxy.
  <br/>
  When using `X-Forwarded-For` with the Docker container, configure
  [`WEBLATE_TRUSTED_PROXY_ADDRESSES`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_TRUSTED_PROXY_ADDRESSES) with the reverse proxies allowed
  to supply client addresses.
  <br/>
  #### HINT
  この設定をデフォルトでオンにすることはできません。適切に設定されていないリバースプロキシ環境では、IP アドレスのスプーフィングを許してしまうためです。

サーバーのホスト名
: [Host](https://www.rfc-editor.org/rfc/rfc7230#section-5.4) ヘッダーは、[`SITE_DOMAIN`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SITE_DOMAIN) の設定と一致させてください。リバースプロキシに追加の設定が必要となることがあります（たとえば、Apache では `ProxyPreserveHost On` を、nginxでは `proxy_set_header Host $host;` が必要です）。
  <br/>
  #### HINT
  CSRF 検証失敗エラーは、[Host](https://www.rfc-editor.org/rfc/rfc7230#section-5.4) ヘッダーと設定された [`SITE_DOMAIN`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SITE_DOMAIN) の間の不一致によって引き起こされることが良くあります。

クライアント プロトコル
: 正しいプロトコル情報が渡されないと、Weblate がクライアントを HTTPS にアップグレードしようとしてリダイレクトループに陥る可能性があります。リバースプロキシによって *X-Forwarded-Proto* として正しく公開されていることを確認してください。
  <br/>
  このヘッダーは、[`SECURE_PROXY_SSL_HEADER`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SECURE_PROXY_SSL_HEADER) （`settings.py`）または [`WEBLATE_SECURE_PROXY_SSL_HEADER`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_SECURE_PROXY_SSL_HEADER) として設定される必要があります。
  <br/>
  #### IMPORTANT
  設定におけるヘッダー値は大文字/小文字を区別するため、`WEBLATE_SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,https` と `WEBLATE_SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,HTTPS` は置き換えられません。
  <br/>
  #### HINT
  ブラウザで "Too many redirects" エラーが出る場合、これは実際のプロトコル（HTTPS）と Weblate が認識するプロトコルとの不一致が原因である可能性が高いです。
  <br/>
  #### Versionchanged
  バージョン 5.13 で変更: デフォルト設定では、プロトコルプロキシヘッダーは **gunicorn** によって自動的に処理されますが、他の WSGI サーバーはより安全な設定を採用しており、この明示的な設定が必要です。
  <br/>
  Weblate 5.13 以降、Docker コンテナは **granian** を使用しており、現在は [`WEBLATE_SECURE_PROXY_SSL_HEADER`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_SECURE_PROXY_SSL_HEADER) の明示的な設定が必要です。

#### SEE ALSO
* [SSL終端プロキシ](https://docs.weblate.org/ja/latest/admin/install/docker.md#docker-ssl-proxy)
* [接続制限](https://docs.weblate.org/ja/latest/admin/optionals.md#rate-limit)
* [監査ログ](https://docs.weblate.org/ja/latest/user/profile.md#audit-log)
* [NGINX および Granian のためのサンプル設定](#nginx-granian)
* [NGINX と Gunicorn の設定例](#nginx-gunicorn)
* [NGINX および uWSGI の設定例](#uwsgi)
* [Apache の設定例](#apache)
* [Apache と Gunicorn の設定例](#apache-gunicorn)
* [`IP_BEHIND_REVERSE_PROXY`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_BEHIND_REVERSE_PROXY)
* [`IP_PROXY_HEADER`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_PROXY_HEADER)
* [`IP_PROXY_OFFSET`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-IP_PROXY_OFFSET)
* [`SECURE_PROXY_SSL_HEADER`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SECURE_PROXY_SSL_HEADER)
* [`WEBLATE_IP_PROXY_HEADER`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_IP_PROXY_HEADER)
* [`WEBLATE_TRUSTED_PROXY_ADDRESSES`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_TRUSTED_PROXY_ADDRESSES)
* [`WEBLATE_IP_PROXY_OFFSET`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_IP_PROXY_OFFSET)

<a id="http-proxy"></a>

### HTTP プロキシ

Weblate supports per-protocol HTTP proxy configuration for outbound HTTP
requests and Git repositories. Define the proxy environment variables in
`settings.py`:

```python
import os

os.environ["http_proxy"] = "http://proxy.example.com:8080"
os.environ["https_proxy"] = "http://proxy.example.com:8080"
```

Only `http_proxy` and `https_proxy` are supported. Generic and bypass
variables such as `all_proxy` and `no_proxy`, operating-system proxy
configuration, and VCS-specific proxy configuration are not supported.

#### SEE ALSO
[Proxy environment variables](https://everything.curl.dev/usingcurl/proxies/env.html)

<a id="configuration"></a>

## 詳細設定

#### SEE ALSO
[設定例](https://docs.weblate.org/ja/latest/admin/sample.md#sample-configuration)

`weblate/settings_example.py` を `weblate/settings.py` にコピーし、設定に合わせて変更します。詳細設定すべきオプション:

<a id="std-setting-ADMINS"></a>

`ADMINS`

> マージの失敗や Django エラーなど、問題が発生したときに通知を受け取るサイト管理者一覧。

> [`ADMINS_CONTACT`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ADMINS_CONTACT) が設定されていない限り、お問い合わせフォームもこれらのメールアドレスへ送信します。

> #### SEE ALSO
> * [`ADMINS`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-ADMINS)
> * [`ADMINS_CONTACT`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ADMINS_CONTACT)
> * [適切な管理者の設定](#production-admins)

<a id="std-setting-ALLOWED_HOSTS"></a>

`ALLOWED_HOSTS`

> サイトでサービスを提供する予定のホスト一覧を設定してください。設定例:

> ```python
> ALLOWED_HOSTS = ["demo.weblate.org"]
> ```

> ワイルドカードの使用例:

> ```python
> ALLOWED_HOSTS = ["*"]
> ```

> #### SEE ALSO
> * [`ALLOWED_HOSTS`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-ALLOWED_HOSTS)
> * [`WEBLATE_ALLOWED_HOSTS`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_ALLOWED_HOSTS)
> * [許可するホストの登録](#production-hosts)

<a id="std-setting-SESSION_ENGINE"></a>

`SESSION_ENGINE`

> セッションの保存方法を設定します。デフォルトのデータベース バックエンド エンジンを使用している場合に必要なスケジュール:　**weblate clearsessions** を使用して、古いセッション データをデータベースから削除します。

> Valkey または Redis をキャッシュとして使用している場合（参照: [キャッシュの設定](#production-cache)）、セッションにも使用してください。設定方法:

> ```python
> SESSION_ENGINE = "django.contrib.sessions.backends.cache"
> ```

> #### SEE ALSO
> * [セッションエンジンを設定する](https://docs.djangoproject.com/ja/stable/topics/http/sessions/#configuring-sessions)
> * [`SESSION_ENGINE`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SESSION_ENGINE)

<a id="std-setting-DATABASES"></a>

`DATABASES`

> データベース サーバーへの接続設定。詳細については、Django のドキュメントを確認してください。

> #### SEE ALSO
> * [Weblate のデータベース設定](#database-setup)
> * [`DATABASES`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-DATABASES)
> * [データベース](https://docs.djangoproject.com/ja/stable/ref/databases/)

<a id="std-setting-DEBUG"></a>

`DEBUG`

> 本番サーバーでは無効にしてください。デバッグ モードを有効にすると、Django はエラーが発生したときユーザーにバックトレースを表示します。無効にすると、エラーはメールで `ADMINS` （上記参照）に送信されます。

> この場合、Django はより多くの情報を内部に格納するので、デバッグ モードは Weblate の速度を低下させます。

> #### SEE ALSO
> * [`DEBUG`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-DEBUG)
> * [デバッグ モードの無効化](#production-debug)

<a id="std-setting-DEFAULT_FROM_EMAIL"></a>

`DEFAULT_FROM_EMAIL`

> メール送信時の送信者のメールアドレス。例: 登録済みのメールアドレス。

> #### SEE ALSO
> [`DEFAULT_FROM_EMAIL`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-DEFAULT_FROM_EMAIL)

<a id="std-setting-SECRET_KEY"></a>

`SECRET_KEY`

> Django が Cookie の情報に署名するために使用するキー。詳細については、[Django の秘密鍵](#production-secret) を確認してください。

> #### SEE ALSO
> [`SECRET_KEY`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SECRET_KEY)

<a id="std-setting-SERVER_EMAIL"></a>

`SERVER_EMAIL`

> 管理者にメール送信する場合の送信者のメールアドレス。例: マージを失敗した時の通知など 。

> #### SEE ALSO
> [`SERVER_EMAIL`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SERVER_EMAIL)

<a id="tables-setup"></a>

## データベースの準備

設定の準備ができたら、[`migrate`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-migrate) を実行してデータベース構造を作成します。これで、管理画面を使用して翻訳プロジェクトを作成できます。

設定が完了したら、管理画面の 性能レポート も確認してください。これにより、サイトの不適切な設定に気づくかもしれません。

#### SEE ALSO
* [設定](https://docs.weblate.org/ja/latest/admin/config.md#config)
* [権限一覧](https://docs.weblate.org/ja/latest/admin/access.md#privileges)

<a id="production"></a>

## 運用環境の設定

運用環境の初期設定では、次のセクションで説明する設定の調整が必要です。最重要の設定時に、スーパーユーザーとしてサインインしている場合、上部バーに感嘆符で警告が表示されます。警告表示例:

![image](screenshots/admin-wrench.webp)

また、Django により実行された検査項目の確認も推奨します（すべての修正は必要はないかもしれない）。検査を確認するコマンド:

```sh
weblate check --deploy
```

また、[管理画面](https://docs.weblate.org/ja/latest/admin/admin.md#management-interface) の [性能レポート](https://docs.weblate.org/ja/latest/admin/admin.md#manage-performance) からも、同一の検査項目を確認できます。

#### SEE ALSO
[デプロイチェックリスト](https://docs.djangoproject.com/ja/stable/howto/deployment/checklist/)

<a id="production-debug"></a>

### デバッグ モードの無効化

Django のデバッグ モード（ [`DEBUG`](#std-setting-DEBUG)）を無効する方法:

```python
DEBUG = False
```

デバッグ モードを有効にすると、Django は実行したすべてのクエリーを保存し、ユーザーにエラーのバック トレースを表示しますが、これは運用環境では望ましくありません。

#### SEE ALSO
[詳細設定](#configuration)

<a id="production-admins"></a>

### 適切な管理者の設定

Set the correct admin addresses to the [`ADMINS`](#std-setting-ADMINS) setting to define who will receive
e-mails in case something goes wrong on the server, for example:

```python
ADMINS = ("Your Name <your_email@example.com>",)
```

#### SEE ALSO
[詳細設定](#configuration)

<a id="production-site"></a>

### サイトの正確なドメイン設定

管理画面からサイト名とドメインを設定してください。設定がされていなければ、RSS のリンクまたはアカウント登録メールは機能しません。設定は、 [`SITE_DOMAIN`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SITE_DOMAIN) にサイトのドメイン名を指定して行います。

#### Versionchanged
バージョン 4.2 で変更: 4.2 以前のリリースでは、代わりに Django sites フレームワークが使用されていました。参照: ["sites" フレームワーク](https://docs.djangoproject.com/ja/stable/ref/contrib/sites/)。

#### SEE ALSO
* [許可するホストの登録](#production-hosts)
* [HTTPS の正しい設定](#production-ssl)
* [`SITE_DOMAIN`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SITE_DOMAIN)
* [`WEBLATE_SITE_DOMAIN`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_SITE_DOMAIN)
* [`ENABLE_HTTPS`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ENABLE_HTTPS)

<a id="production-ssl"></a>

### HTTPS の正しい設定

暗号化された HTTPS プロトコルを使用して Weblate を実行することを強く推奨します。有効にしたら、設定画面から [`ENABLE_HTTPS`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ENABLE_HTTPS) を設定してください。設定例:

```python
ENABLE_HTTPS = True
```

#### HINT
HSTS も設定してください。詳細については、[SSL/HTTPS](https://docs.djangoproject.com/ja/stable/topics/security/#security-recommendation-ssl) を確認してください。

#### SEE ALSO
* [`ENABLE_HTTPS`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ENABLE_HTTPS)
* [許可するホストの登録](#production-hosts)
* [サイトの正確なドメイン設定](#production-site)

### SECURE_HSTS_SECONDS の適切な設定

サイトを SSL で提供している場合、HTTP Strict Transport Security を有効にするには、`settings.py` 内の [`SECURE_HSTS_SECONDS`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SECURE_HSTS_SECONDS) の値を設定してください。デフォルトでは以下のように、 0 に設定されています。

```python
SECURE_HSTS_SECONDS = 0
```

ゼロ以外の整数値に設定すると、[`django.middleware.security.SecurityMiddleware`](https://docs.djangoproject.com/ja/stable/ref/middleware/#django.middleware.security.SecurityMiddleware) は、[HTTP Strict Transport Security](https://docs.djangoproject.com/ja/stable/ref/middleware/#http-strict-transport-security) ヘッダーがまだないすべてのレスポンスに設定します。

#### WARNING
これを誤って設定すると、元に戻せないほど（しばらくの間）サイトが壊れることがあります。はじめに [HTTP Strict Transport Security](https://docs.djangoproject.com/ja/stable/ref/middleware/#http-strict-transport-security) のドキュメントを読んでください。

<a id="production-database"></a>

### 強力なデータベース エンジンの使用

* 運用環境では PostgreSQL を使用してください。詳細については、[Weblate のデータベース設定](#database-setup) を確認してください。
* データベース サーバーは、近くのロケーションに設置してください。そうしなければ、ネットワークのパフォーマンスや信頼性が原因で、Weblate が使用できなくなることがあります。
* 例えば [PGTune](https://pgtune.leopard.in.ua/) を使用して、データベース サーバーの性能の検査をしたり、設定を調整してください。
* Weblate deployment checks report non-finite PostgreSQL relation statistics.
  Run `ANALYZE` on the reported relations to rebuild corrupted statistics.

#### SEE ALSO
* [Weblate のデータベース設定](#database-setup)
* [他のデータベースから PostgreSQL に移行](https://docs.weblate.org/ja/latest/admin/upgrade.md#database-migration)
* [詳細設定](#configuration)
* [データベース](https://docs.djangoproject.com/ja/stable/ref/databases/)

<a id="production-cache"></a>

### キャッシュの設定

できれば、設定変数 `CACHES` を変更して Django から Valkey または Redis を使用します。設定の変更例:

```python
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/0",
        # If redis is running on same host as Weblate, you might
        # want to use unix sockets instead:
        # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PARSER_CLASS": "redis.connection.HiredisParser",
        },
    }
}
```

#### HINT
キャッシュの設定を変更する場合は、Celery 用の設定も調整することが必要です。参照: [Celery を使用するバックグラウンド タスク](#celery)。

#### SEE ALSO
* [アバターのキャッシュ](#production-cache-avatar)
* [Django のキャッシュフレームワーク](https://docs.djangoproject.com/ja/stable/topics/cache/)

<a id="production-cache-avatar"></a>

### アバターのキャッシュ

Django のキャッシュに加えて、Weblate はアバターのキャッシュも行います。そちらは、独立したファイルベースのキャッシュにすることをおすすめします:

```python
CACHES = {
    "default": {
        # Default caching backend setup, see above
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "unix:///var/run/redis/redis.sock?db=0",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PARSER_CLASS": "redis.connection.HiredisParser",
        },
    },
    "avatar": {
        "BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
        "LOCATION": os.path.join(DATA_DIR, "avatar-cache"),
        "TIMEOUT": 604800,
        "OPTIONS": {
            "MAX_ENTRIES": 1000,
        },
    },
}
```

#### SEE ALSO
* [`ENABLE_AVATARS`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-ENABLE_AVATARS)
* [`AVATAR_URL_PREFIX`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-AVATAR_URL_PREFIX)
* [アバター](https://docs.weblate.org/ja/latest/admin/optionals.md#avatars)
* [キャッシュの設定](#production-cache)
* [Django のキャッシュフレームワーク](https://docs.djangoproject.com/ja/stable/topics/cache/)

<a id="production-email"></a>

### メールの送信設定

Weblate は、たびたびメールを送信します。そのため、送信者のメールアドレスは正確に設定してください。環境に合わせて [`SERVER_EMAIL`](#std-setting-SERVER_EMAIL) および [`DEFAULT_FROM_EMAIL`](#std-setting-DEFAULT_FROM_EMAIL) の設定が必要です。メール送信の設定例:

```python
SERVER_EMAIL = "admin@example.org"
DEFAULT_FROM_EMAIL = "weblate@example.org"
```

#### NOTE
Weblate からのメール送信を無効にするには、[`EMAIL_BACKEND`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_BACKEND) を `django.core.mail.backends.dummy.EmailBackend` に設定します。

これにより、登録やパスワード リセットを含む  *すべての* メール配信が無効となります。

#### SEE ALSO
* [詳細設定](#configuration)
* [メール送信の設定](#out-mail)
* [`EMAIL_BACKEND`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-EMAIL_BACKEND)
* [`DEFAULT_FROM_EMAIL`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-DEFAULT_FROM_EMAIL)
* [`SERVER_EMAIL`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-SERVER_EMAIL)

<a id="production-hosts"></a>

### 許可するホストの登録

Django では、サイトの使用を許可するドメイン名のリストは、[`ALLOWED_HOSTS`](#std-setting-ALLOWED_HOSTS) への登録が必要です。空のままだと、リクエストはブロックされて接続できません。

HTTP サーバーと一致するように設定されていない場合、以下のようなエラーが発生します。`Invalid HTTP_HOST header: '1.1.1.1'. You may need to add '1.1.1.1' to ALLOWED_HOSTS.`

#### HINT
Docker コンテナでは、[`WEBLATE_ALLOWED_HOSTS`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_ALLOWED_HOSTS) を使用します。

#### SEE ALSO
* [`ALLOWED_HOSTS`](#std-setting-ALLOWED_HOSTS)
* [`WEBLATE_ALLOWED_HOSTS`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_ALLOWED_HOSTS)
* [サイトの正確なドメイン設定](#production-site)

<a id="production-secret"></a>

### Django の秘密鍵

[`SECRET_KEY`](#std-setting-SECRET_KEY) 設定は、Django が cookie に署名するために使用します。サンプルの設定値を使用せず、独自の値を実際に生成してください。

新しい秘密鍵の生成には、Weblate 付属の **weblate-generate-secret-key** を使用できます。

#### SEE ALSO
[`SECRET_KEY`](#std-setting-SECRET_KEY)

<a id="production-cron"></a>

### メンテナンス タスクの実行

パフォーマンスを最適化するには、メンテナンス タスクをバックグラウンドで実行させることが望ましいです。これは、[Celery を使用するバックグラウンド タスク](#celery) により自動的に実行されます。celery が実行するタスク:

* 設定の健全性診断（毎時）。
* 保留中の変更のコミット（毎時）。参照: [遅延コミット](https://docs.weblate.org/ja/latest/admin/continuous.md#lazy-commit) および [`commit_pending`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-commit_pending)。
* コンポーネントの警告の更新（毎日）。
* リモート ブランチの（毎晩）更新。参照: [`AUTO_UPDATE`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-AUTO_UPDATE)。
* JSON への翻訳メモリのバックアップ（毎日）。参照: [`dump_memory`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-dump_memory)。
* 全文およびデータベースの保守タスク（毎日および毎週のタスク）。参照: [`cleanuptrans`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-cleanuptrans)。

<a id="production-encoding"></a>

### システム言語とエンコーディング

システム言語は、UTF-8 対応の言語に設定してください。ほとんどの Linux ディストリビューションでは、UTF-8 がデフォルトの設定です。使用するシステムが該当しない場合は、言語を UTF-8 形式に変更してください。

例えば、`/etc/default/locale` を編集して、 `LANG="C.UTF-8"` を設定します。

場合によっては、個々のサービスには言語ごとに個別の設定があります。これはディストリビューションと Web サーバーによって異なるため、Web サーバー パッケージのドキュメントを確認してください。

Ubuntu の Apache で使用する `/etc/apache2/envvars` の設定例:

```sh
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
```

CentOS の Apache で使用する `/etc/sysconfig/httpd` （または `/opt/rh/httpd24/root/etc/sysconfig/httpd`） の設定例:

```sh
LANG='en_US.UTF-8'
```

<a id="production-certs"></a>

### カスタム認証局の使用

Weblate verifies SSL certificates during HTTP requests. Requests made using
HTTPX2 use the system certificate store, so install custom certificate
authorities there.

Check your distribution documentation for more details. For example, on Debian
this can be done by placing the CA certificate into
`/usr/local/share/ca-certificates/` and running
**update-ca-certificates**.

#### HINT
Weblate コンテナはそれを検索パスに含んでいないため、実行するにはフルパスを指定する必要があります。例:

```sh
docker compose exec -u root weblate /usr/sbin/update-ca-certificates
```

Once this is done, Weblate HTTPX2 requests and system tools, including Git, will
trust the certificate.

Some integrations, including OAuth and OpenID Connect authentication, use
Requests, which does not use the system certificate store by default. When
these integrations communicate with services using the custom certificate
authority, configure Requests to use the system CA bundle by adding the
following to `settings.py` (the path is Debian-specific):

```python
import os

os.environ["REQUESTS_CA_BUNDLE"] = "/etc/ssl/certs/ca-certificates.crt"
```

<a id="server"></a>

## 実行サーバー

#### HINT
下記で説明しているサービスの設定に慣れていない場合は、[Docker を使用したインストール](https://docs.weblate.org/ja/latest/admin/install/docker.md) を試してください。

Weblate の実行に必要なサービスと推奨設定:

* データベース サーバー（参照: [Weblate のデータベース設定](#database-setup) ）
* キャッシュ サーバー（参照: [キャッシュの設定](#production-cache) ）
* 静的ファイルと SSL ターミネーション用のフロントエンド Web サーバー（参照: [静的ファイルの提供](#static-files) ）
* 動的コンテンツ用の WSGI サーバー（参照: [NGINX および uWSGI の設定例](#uwsgi) ）
* バックグラウンド タスク実行用の Celery（参照: [Celery を使用するバックグラウンド タスク](#celery) ）

#### NOTE
サービス間には、依存関係があります。例えば、Celery または uwsgi プロセスの起動時には、キャッシュとデータベース サーバーが実行されていることが必要です。

多くの場合、すべてのサービスを単一の（仮想）サーバー上で実行しますが、インストールの負荷が高い場合は、サービスを分割できます。唯一の制限は、Celery サーバーと Wsgi サーバーは [`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) へのアクセス権が必要なことです。

#### NOTE
WSGI プロセスは、Celery プロセスと同じユーザーとして実行させてください。もし異なる場合は、[`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) 内のファイルの所有権が混在した状態で保存され、実行時に問題が発生します。

[ファイル システムのアクセス権](#file-permissions) および [Celery を使用するバックグラウンド タスク](#celery) も確認してください。

### Web サーバーの実行

Weblate の実行は、他の Django ベースのプログラムの実行と同じです。通常 Django は WSGI または fcgi として実行されます（下記の異なる webservers の例を参照）。

#### NOTE
The sample configuration files shown below are maintained in the Weblate
source tree under `weblate/examples/`. They are included in source
distributions and in this documentation, but Python wheels only install
runtime files. When installing Weblate from PyPI, get the matching source
distribution or source checkout before copying these examples.

テスト目的のために、Django の内蔵 Web サーバーを使用できます。Web サーバー実行コマンド:

```sh
weblate runserver
```

#### WARNING
Django の内蔵 Web サーバーは、運用環境では使用しないでください。セキュリティ監査や性能試験を受けていません。 [`runserver`](https://docs.djangoproject.com/ja/stable/ref/django-admin/#django-admin-runserver) の Django ドキュメントも確認してください。

#### HINT
Django に内蔵された Web サーバーは、開発専用であるため、[`DEBUG`](#std-setting-DEBUG) が有効な場合にのみ静的ファイルが提供されます。運用環境で使用するには、WSGI 設定を確認してください。

* [NGINX および Granian のためのサンプル設定](#nginx-granian)
* [NGINX と Gunicorn の設定例](#nginx-gunicorn)
* [NGINX および uWSGI の設定例](#uwsgi)
* [Apache の設定例](#apache)
* [Apache と Gunicorn の設定例](#apache-gunicorn)
* [静的ファイルの提供](#static-files)

<a id="static-files"></a>

### 静的ファイルの提供

#### Versionchanged
バージョン 5.15.2 で変更: `/media/` はスクリーンショットの提供には使用されなくなりました。

Django needs to collect its static files in a single directory. To do so,
execute `weblate collectstatic --noinput`. This will copy the static
files into a directory specified by the [`STATIC_ROOT`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-STATIC_ROOT) setting (this defaults to
a `static` directory inside [`CACHE_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CACHE_DIR)). Production installations
use content hashes in collected filenames so that updated assets do not reuse
stale browser or proxy caches.

静的ファイルは、Web サーバーから直接提供することが望ましいです。静的ファイルが必要となるパス:

`/static/`
: Weblate および管理画面の静的ファイルの提供（[`STATIC_ROOT`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-STATIC_ROOT) に設定済）。

`/favicon.ico`
: Should be rewritten to serve `/static/favicon.ico`.

#### SEE ALSO
* [NGINX および Granian のためのサンプル設定](#nginx-granian)
* [NGINX と Gunicorn の設定例](#nginx-gunicorn)
* [NGINX および uWSGI の設定例](#uwsgi)
* [Apache の設定例](#apache)
* [Apache と Gunicorn の設定例](#apache-gunicorn)
* [Djangoをデプロイするには](https://docs.djangoproject.com/ja/stable/howto/deployment/)
* [静的ファイルをデプロイする](https://docs.djangoproject.com/ja/stable/howto/static-files/deployment/)

<a id="csp"></a>

### コンテンツ セキュリティ ポリシー

Weblate のデフォルト設定では、`weblate.middleware.SecurityMiddleware` ミドルウェアが有効となり、*Content-Security-Policy* または *X-XSS-Protection* などのセキュリティ関連の HTTP ヘッダーが設定されます。デフォルトでは、これらは Weblate の設定で動作するように設定されていますが、環境によっては変更が必要です。

#### SEE ALSO
* [`CSP_SCRIPT_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_SCRIPT_SRC)
* [`CSP_IMG_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_IMG_SRC)
* [`CSP_CONNECT_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_CONNECT_SRC)
* [`CSP_STYLE_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_STYLE_SRC)
* [`CSP_FONT_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_FONT_SRC)
* [`CSP_FORM_SRC`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-CSP_FORM_SRC)

<a id="nginx-granian"></a>

### NGINX および Granian のためのサンプル設定

The following configuration runs Weblate using Granian with the NGINX webserver:

```nginx
#
# nginx configuration for Weblate
#
# You will want to change:
#
# - server_name
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change python3.12 to match your Python version
# - change weblate user to match your Weblate user
#
server {
    listen 80;
    server_name weblate;
    # Not used
    root /var/www/html;

    location ~ ^/favicon.ico$ {
        # CACHE_DIR/static/favicon.ico
        alias /home/weblate/data/cache/static/favicon.ico;
        expires 30d;
    }

    location /static/ {
        # CACHE_DIR/static/
        alias /home/weblate/data/cache/static/;
        expires 30d;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:8888;
        proxy_read_timeout 3600;
    }
}
```

#### SEE ALSO
* [Granianを起動するための設定例](#running-granian)
* [https://github.com/emmett-framework/granian](https://github.com/emmett-framework/granian)
* [WSGI とともにデプロイするには](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/)

<a id="nginx-gunicorn"></a>

### NGINX と Gunicorn の設定例

The following configuration runs Weblate using Gunicorn under the NGINX webserver
(`weblate/examples/weblate.nginx.gunicorn.conf` in the source tree):

```nginx
#
# nginx configuration for Weblate
#
# You will want to change:
#
# - server_name
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change python3.12 to match your Python version
# - change weblate user to match your Weblate user
#
server {
    listen 80;
    server_name weblate;
    # Not used
    root /var/www/html;

    location ~ ^/favicon.ico$ {
        # CACHE_DIR/static/favicon.ico
        alias /home/weblate/data/cache/static/favicon.ico;
        expires 30d;
    }

    location /static/ {
        # CACHE_DIR/static/
        alias /home/weblate/data/cache/static/;
        expires 30d;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_pass http://unix:/run/gunicorn.sock;
        proxy_read_timeout 3600;
    }
}
```

#### SEE ALSO
* [Gunicorn を起動するための設定例](#running-gunicorn)
* [Django を Gunicorn とともに使う](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/gunicorn/)

<a id="uwsgi"></a>

### NGINX および uWSGI の設定例

運用環境の WEB サーバーを実行するには、Weblate とともにインストールされた WSGI ラッパーを使用します（Python 環境を利用している場合は `~/weblate-env/lib/python3.14/site-packages/weblate/wsgi.py` としてインストールされます）。 また、Python の検索パスを使用している Python 環境に設定することも忘れないでください（例: uWSGI で `virtualenv = /home/user/weblate-env` の指定）。

次の設定では、NGINX WEB サーバーの下で Weblate を uWSGI として実行します。

Configuration for NGINX (`weblate/examples/weblate.nginx.conf` in the source tree):

```nginx
#
# nginx configuration for Weblate
#
# You will want to change:
#
# - server_name
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change python3.12 to match your Python version
# - change weblate user to match your Weblate user
#
server {
    listen 80;
    server_name weblate;
    # Not used
    root /var/www/html;

    location ~ ^/favicon.ico$ {
        # CACHE_DIR/static/favicon.ico
        alias /home/weblate/data/cache/static/favicon.ico;
        expires 30d;
    }

    location /static/ {
        # CACHE_DIR/static/
        alias /home/weblate/data/cache/static/;
        expires 30d;
    }

    location / {
        include uwsgi_params;
        # Needed for long running operations in admin interface
        uwsgi_read_timeout 3600;
        # Adjust based to uwsgi configuration:
        uwsgi_pass unix:///run/uwsgi/app/weblate/socket;
        # uwsgi_pass 127.0.0.1:8080;
    }
}
```

Configuration for uWSGI (`weblate/examples/weblate.uwsgi.ini` in the source tree):

```ini
#
# uWSGI configuration for Weblate
#
# You will want to change:
#
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change python3.12 to match your Python version
# - change weblate user to match your Weblate user
#
[uwsgi]
plugins       = python3
master        = true
protocol      = uwsgi
socket        = 127.0.0.1:8080
wsgi-file     = /home/weblate/weblate-env/lib/python3.12/site-packages/weblate/wsgi.py

# Add path to Weblate checkout if you did not install
# Weblate by pip
# python-path   = /path/to/weblate

# Path to the Python environment
virtualenv = /home/weblate/weblate-env

# Set sys.executable so Python helpers run with the virtual environment's Python
py-executable = /home/weblate/weblate-env/bin/python

# Needed for OAuth/OpenID
buffer-size   = 8192

# Reload when consuming too much of memory
reload-on-rss = 250

# Increase number of workers for heavily loaded sites
workers       = 8

# Enable threads for Sentry error submission
enable-threads = true

# Child processes do not need file descriptors
close-on-exec = true

# Avoid default 0000 umask
umask = 0022

# Run as weblate user
uid = weblate
gid = weblate

# Enable harakiri mode (kill requests after some time)
# harakiri = 3600
# harakiri-verbose = true

# Enable uWSGI stats server
# stats = :1717
# stats-http = true

# Do not log some errors caused by client disconnects
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true
```

Set `py-executable` to the absolute path of `bin/python` inside the
environment configured by `virtualenv`. Weblate uses Python's
`sys.executable` to launch helper processes, including the SSH connection
proxy used for Git repositories. uWSGI can otherwise set this value to its own
executable, causing repository operations to fail with an error such as
`/usr/bin/uwsgi-core: invalid option -- 'I'`. Setting `virtualenv` alone does
not ensure that `sys.executable` points to Python. Restart uWSGI after updating
the configuration.

#### SEE ALSO
[Django を uWSGI とともに使うには？](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/uwsgi/)

<a id="apache"></a>

### Apache の設定例

Weblate で WSGI を使用する場合は、prefork MPM を使用することが望ましいです。

The following configuration runs Weblate as WSGI, you need to have enabled
`mod_wsgi` (`weblate/examples/apache.conf` in the source tree):

```apache
#
# VirtualHost for Weblate
#
# You will want to change:
#
# - ServerAdmin and ServerName
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change python3.12 to match Python version mod-wsgi is compiled for
# - change weblate user to match your Weblate user
#
<VirtualHost *:80>
    ServerAdmin admin@weblate.example.org
    ServerName weblate.example.org

    # CACHE_DIR/static/favicon.ico
    Alias /favicon.ico /home/weblate/data/cache/static/favicon.ico

    # CACHE_DIR/static/
    Alias /static/ /home/weblate/data/cache/static/
    <Directory /home/weblate/data/cache/static/>
        Require all granted
    </Directory>

    # Path to your Weblate Python environment
    WSGIDaemonProcess weblate python-home=/home/weblate/weblate-env user=weblate request-timeout=600
    WSGIProcessGroup weblate
    WSGIApplicationGroup %{GLOBAL}

    WSGIScriptAlias / /home/weblate/weblate-env/lib/python3.12/site-packages/weblate/wsgi.py process-group=weblate
    WSGIPassAuthorization On

    <Directory /home/weblate/weblate-env/lib/python3.12/site-packages/weblate/>
        <Files wsgi.py>
        Require all granted
        </Files>
    </Directory>

</VirtualHost>
```

#### NOTE
Weblate には Python 3 が必要なので、Python 3 版の modwsgi が実行されていることを確認してください。通常は、`libapache2-mod-wsgi-py3` のように、別のパッケージとして提供されています。

一致する Python バージョンを使用して Weblate をインストールします。

#### SEE ALSO
* [システム言語とエンコーディング](#production-encoding)
* [Django を Apache と mod_wsgi とともに使うには？](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/modwsgi/)

<a id="apache-gunicorn"></a>

### Apache と Gunicorn の設定例

The following configuration runs Weblate in Gunicorn and Apache 2.4
(`weblate/examples/apache.gunicorn.conf` in the source tree):

```apache
#
# VirtualHost for Weblate using gunicorn on localhost:8000
#
# You will want to change:
#
# - ServerAdmin and ServerName
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change weblate user to match your Weblate user
#
<VirtualHost *:443>
    ServerAdmin admin@weblate.example.org
    ServerName weblate.example.org

    # CACHE_DIR/static/favicon.ico
    Alias /favicon.ico /home/weblate/data/cache/static/favicon.ico

    # CACHE_DIR/static/
    Alias /static/ /home/weblate/data/cache/static/
    <Directory /home/weblate/data/cache/static/>
        Require all granted
    </Directory>

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/https_cert.cert
    SSLCertificateKeyFile /etc/apache2/ssl/https_key.pem
    SSLProxyEngine On

    ProxyPass /favicon.ico !
    ProxyPass /static/ !

    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    ProxyPreserveHost On
</VirtualHost>
```

#### SEE ALSO
* [Gunicorn を起動するための設定例](#running-gunicorn)
* [Django を Gunicorn とともに使う](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/gunicorn/)

<a id="running-granian"></a>

### Granianを起動するための設定例

Weblate には wsgi オプションの依存関係（[Python の依存関係](#python-deps)）があり、これには Granian を実行するために必要なすべてが含まれます。Weblate をインストールする際には、次のように指定できます:

```shell
uv pip install Weblate[all,wsgi]
```

Granian のインストール後、実行可能です。これは通常システムレベルで行われます。systemd を使った起動例を以下に示します:

```ini
[Unit]
Description=granian daemon
After=network.target

[Service]
User=weblate
Group=weblate
WorkingDirectory=/home/weblate/weblate-env/
Environment="DJANGO_SETTINGS_MODULE=weblate.settings"
RuntimeDirectory=granian
ExecStart=/home/weblate/weblate-env/bin/granian \
    --no-ws \
    --workers-max-rss 450 \
    --interface wsgi \
    --workers 2 \
    --blocking-threads 8 \
    --backlog 128 \
    --backpressure 16 \
    --runtime-mode mt \
    --port 8888 \
    weblate.wsgi:application

[Install]
WantedBy=multi-user.target
```

Granian uses worker processes for parallel Python execution, blocking threads
for concurrent WSGI requests, and runtime threads for network I/O. The sample
uses two workers with eight blocking threads each, limits each worker to 16
concurrent connections, and leaves the runtime threads at Granian's default.
Adjust the workers and blocking threads to the available memory, CPU cores, and
database connection limit. Keep the backpressure equal to or higher than the
number of blocking threads.

#### SEE ALSO
* [Sample configuration to start Granian with ASGI](#running-granian-asgi)
* [https://github.com/emmett-framework/granian](https://github.com/emmett-framework/granian)
* [WSGI とともにデプロイするには](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/)

<a id="running-granian-asgi"></a>

### Sample configuration to start Granian with ASGI

#### Versionadded
Added in version 2026.8.

ASGI deployment is available as an opt-in alternative to WSGI. Install the
`asgi` optional dependency:

```shell
uv pip install Weblate[all,asgi]
```

The following systemd unit runs the Django ASGI application:

```ini
[Unit]
Description=granian ASGI daemon
After=network.target

[Service]
User=weblate
Group=weblate
WorkingDirectory=/home/weblate/weblate-env/
Environment="DJANGO_SETTINGS_MODULE=weblate.settings"
RuntimeDirectory=granian
ExecStart=/home/weblate/weblate-env/bin/granian \
    --no-ws \
    --workers-max-rss 450 \
    --interface asginl \
    --workers 2 \
    --backlog 128 \
    --backpressure 16 \
    --runtime-mode mt \
    --port 8888 \
    weblate.asgi:application

[Install]
WantedBy=multi-user.target
```

The sample uses Granian's ASGI interface without lifespan or WebSocket support,
because Weblate currently exposes HTTP only. Weblate's middleware supports both
deployment modes and uses thread-sensitive adapters where it still relies on
synchronous Django APIs. The health check is asynchronous, but most Weblate
views remain synchronous, and CPU-intensive or long-running work should still
be handled by [Celery を使用するバックグラウンド タスク](#celery).

WSGI remains the default deployment mode. Docker images can opt in to ASGI by
setting [`WEBLATE_ASGI`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_ASGI) to `1`. Adjust the worker count and
backpressure to the available memory, CPU cores, and database connection limit.

#### SEE ALSO
* [Granianを起動するための設定例](#running-granian)
* [https://github.com/emmett-framework/granian](https://github.com/emmett-framework/granian)
* [ASGI とともにデプロイするには](https://docs.djangoproject.com/ja/stable/howto/deployment/asgi/)

<a id="running-gunicorn"></a>

### Gunicorn を起動するための設定例

Gunicorn は別途インストールする必要があります:

```shell
uv pip install gunicorn
```

Gunicorn のインストール後、実行可能です。これは通常システムレベルで行われます。systemd を使った起動例を以下に示します:

```ini
[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target
```

```ini
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=weblate
Group=weblate
WorkingDirectory=/home/weblate/weblate-env/
Environment="DJANGO_SETTINGS_MODULE=weblate.settings"
ExecStart=/home/weblate/weblate-env/bin/gunicorn \
    --preload \
    --timeout 3600 \
    --graceful-timeout 3600 \
    --worker-class=gthread \
    --workers=2 \
    --threads=16 \
    --bind unix:/run/gunicorn.sock \
    weblate.wsgi:application

[Install]
WantedBy=multi-user.target
```

#### SEE ALSO
[Django を Gunicorn とともに使う](https://docs.djangoproject.com/ja/stable/howto/deployment/wsgi/gunicorn/)

### パスの下での Weblate の実行

Weblate で WSGI を使用する場合は、prefork MPM を使用することが望ましいです。

A sample Apache configuration to serve Weblate under `/weblate`. Again using
`mod_wsgi` (`weblate/examples/apache-path.conf` in the source tree):

```apache
#
# VirtualHost for Weblate, running under /weblate path
#
# You will want to change:
#
# - ServerAdmin and ServerName
# - change /home/weblate/weblate-env to location where Weblate Python environment is placed
# - change /home/weblate/data to match your DATA_DIR
# - change /home/weblate/data/cache to match your CACHE_DIR
# - change python3.12 to match Python version mod-wsgi is compiled for
# - change weblate user to match your Weblate user
#
<VirtualHost *:80>
    ServerAdmin admin@weblate.example.org
    ServerName weblate.example.org

    # CACHE_DIR/static/favicon.ico
    Alias /weblate/favicon.ico /home/weblate/data/cache/static/favicon.ico

    # CACHE_DIR/static/
    Alias /weblate/static/ /home/weblate/data/cache/static/
    <Directory /home/weblate/data/cache/static/>
        Require all granted
    </Directory>

    # Path to your Weblate Python environment
    WSGIDaemonProcess weblate python-home=/home/weblate/weblate-env user=weblate request-timeout=600
    WSGIProcessGroup weblate
    WSGIApplicationGroup %{GLOBAL}

    WSGIScriptAlias /weblate /home/weblate/weblate-env/lib/python3.12/site-packages/weblate/wsgi.py process-group=weblate
    WSGIPassAuthorization On

    <Directory /home/weblate/weblate-env/lib/python3.12/site-packages/weblate/>
        <Files wsgi.py>
        Require all granted
        </Files>
    </Directory>

</VirtualHost>
```

さらに、`weblate/settings.py` の変更が必要です。

```python
URL_PREFIX = "/weblate"
```

<a id="celery"></a>

## Celery を使用するバックグラウンド タスク

Weblate は Celery を使用して、通常のタスクとバックグラウンド タスクを実行します。タスクを実行する Celery サービスを実行してください。 Celery で動作する処理の例（このリストは完全ではありません）:

* 外部サービスによる Web フックの受信（参照: [通知フック](https://docs.weblate.org/ja/latest/api.md#hooks)）。
* バックアップ、クリーンアップ、毎日動作のアドオン、更新などの定期的なメンテナンス タスクの実行（参照: [Weblate のバックアップと移動](https://docs.weblate.org/ja/latest/admin/backup.md#backup)、[`BACKGROUND_TASKS`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-BACKGROUND_TASKS)、[アドオン](https://docs.weblate.org/ja/latest/admin/addons.md#addons)）。
* [自動翻訳](https://docs.weblate.org/ja/latest/user/translating.md#auto-translation) の実行。
* ダイジェスト通知の送信。
* WSGI プロセスから負荷の高い操作をオフロードさせる。
* 保留中の変更のコミット（参照: [遅延コミット](https://docs.weblate.org/ja/latest/admin/continuous.md#lazy-commit)）。

Valkey または Redis をバックエンドとして使用する一般的な設定例:

```python
CELERY_TASK_ALWAYS_EAGER = False
CELERY_BROKER_URL = "redis://localhost:6379"
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
```

#### SEE ALSO
[Redis broker configuration in Celery](https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/redis.html#broker-redis-configuration)

You should also start the Celery worker to process the tasks and start scheduled
tasks. For debugging or development, this can be done directly on the
command-line:

```sh
celery --app=weblate.utils worker --beat \
    --queues=celery,notify,memory,translate,backup \
    --prefetch-multiplier=1
```

Running all queues in one prefork worker shares the initial application memory
between its child processes while retaining parallel task execution. Celery
determines the concurrency from the number of available CPUs by default; use
`--concurrency` to adjust it for your workload and available memory.

To reduce startup memory usage, Celery workers do not repeat the Django system
checks. The Weblate container runs the more comprehensive
**weblate check --deploy** automatically during container startup. For
other installation methods, run the command after installation, upgrades, or
configuration changes. The checks are also available in the
[management interface](https://docs.weblate.org/ja/latest/admin/admin.md#manage-performance).

#### NOTE
Celery プロセスは、WSGI プロセスと同じユーザーとして実行させてください。もし異なると、[`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) 内のファイルの所有権は混在した状態で保存され、実行時に問題が発生します。

[ファイル システムのアクセス権](#file-permissions) および [実行サーバー](#server) も確認してください。

### eager モードよる WSGI での Celery タスクの実行

#### NOTE
これは、Web インタフェースに深刻な性能上の影響を与えます。そして、定期的なトリガーで起動する操作（例えば、保留中の変更のコミット、ダイジェスト通知、またはバックアップなど）が中断されます。

開発時には、すべてのタスクを適切に処理する Eager を設定してください。Eager 設定例:

```python
CELERY_TASK_ALWAYS_EAGER = True
CELERY_BROKER_URL = "memory://"
CELERY_TASK_EAGER_PROPAGATES = True
```

### システム サービスとして実行する Celery

Most likely you will want to run Celery as a daemon and that is covered by
[Daemonization](https://docs.celeryq.dev/en/stable/userguide/daemonizing.html). For the most common Linux setup using
systemd, adapt the example files listed below. These examples are maintained in
the Weblate source tree under `weblate/examples/`; Python wheels do not
install these deployment samples.

`/etc/systemd/system/celery-weblate.service` に記述する Systemd ユニットの設定方法:

```ini
[Unit]
Description=Celery Service (Weblate)
After=network.target

[Service]
Type=forking
User=weblate
Group=weblate
EnvironmentFile=/etc/default/celery-weblate
WorkingDirectory=/home/weblate
RuntimeDirectory=celery
RuntimeDirectoryPreserve=restart
LogsDirectory=celery
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
  --pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'

[Install]
WantedBy=multi-user.target
```

`/etc/default/celery-weblate` に記述する環境設定の記述例:

```sh
# Name of nodes to start
CELERYD_NODES="combined"

# Absolute or relative path to the 'celery' command:
CELERY_BIN="/home/weblate/weblate-env/bin/celery"

# App instance to use
# comment out this line if you don't use an app
CELERY_APP="weblate.utils"

# Extra command-line arguments to the worker. Celery determines concurrency
# from the number of available CPUs by default. You might need to customize it
# depending on the available resources and Weblate usage. Increase concurrency
# if you get weblate.E019 error, decrease it on a low-resource system.
# Command-line values override corresponding Celery settings in settings.py.
CELERYD_OPTS="--beat:combined --queues:combined=celery,notify,memory,translate,backup --prefetch-multiplier:combined=1"

# Logging configuration
# - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index
#   and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/run/celery/weblate-%n.pid"
CELERYD_LOG_FILE="/var/log/celery/weblate-%n%I.log"
CELERYD_LOG_LEVEL="INFO"
```

`/etc/logrotate.d/celery` にある Celery ログを **logrotate** を使用してローテーションするための追加設定の記述例:

```text
/var/log/celery/*.log {
        weekly
        missingok
        rotate 12
        compress
        notifempty
}
```

### Celery beat を使用した定期的なタスク

Weblate には、スケジュール済みのタスクが初期設定されています。タスク スケジュールはデータベースに保存され、Celery beat デーモンによって実行されます。

#### HINT
追加タスクは `settings.py` で定義できます。たとえば、[遅延コミット](https://docs.weblate.org/ja/latest/admin/continuous.md#lazy-commit) を参照してください。

<a id="monitoring-celery"></a>

### Celery の状態の監視

Celery タスク キューの現在の長さは、[管理画面](https://docs.weblate.org/ja/latest/admin/admin.md#management-interface) から確認できますし、コマンドラインを使用して [`celery_queues`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-celery_queues) からも確認できます。キューが長くなりすぎると、管理画面にも設定エラーが表示されます。

#### WARNING
デフォルトでは、Celery エラーは Celery ログにのみ記録され、ユーザーには表示されません。このような障害の概要を知りたいときは、[エラーレポートの収集とパフォーマンスの監視](#collecting-errors) の設定をしてください。

#### SEE ALSO
* [Weblate の監視](#monitoring)
* [Weblate が正しく設定されているかどうかを確認する方法は？](https://docs.weblate.org/ja/latest/faq.md#faq-monitoring)
* [Configuration and defaults](https://docs.celeryq.dev/en/stable/userguide/configuration.html)
* [Workers Guide](https://docs.celeryq.dev/en/stable/userguide/workers.html)
* [Daemonization](https://docs.celeryq.dev/en/stable/userguide/daemonizing.html)
* [Monitoring and Management Guide](https://docs.celeryq.dev/en/stable/userguide/monitoring.html)
* [バックグラウンド タスクの内部構造](https://docs.weblate.org/ja/latest/contributing/internals.md#background-tasks-internals)
* [`celery_queues`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-celery_queues)

<a id="minimal-celery"></a>

### シングルプロセス Celery の設定

メモリが非常に限られている場合は、Weblate のプロセス数を減らしてみてください。すべての Celery タスクをシングルプロセスで実行する設定:

```sh
celery --app=weblate.utils worker --beat --queues=celery,notify,memory,translate,backup --pool=solo
```

An installation using Docker can be configured to use a single-process Celery
setup by setting `CELERY_WORKER_MODE=single`. See
[`CELERY_WORKER_MODE`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-CELERY_WORKER_MODE).

#### WARNING
これにより、Weblate の性能に顕著な影響が出ます。

<a id="monitoring"></a>

## Weblate の監視

Weblate は、Kubernetes などを使用した簡単に健全性診断ができる `/healthz/` URLを提供しています。Docker コンテナには、この URL を使用した健全性診断が付属しています。

For monitoring metrics of Weblate you can use the [`GET /api/metrics/`](https://docs.weblate.org/ja/latest/api.md#get--api-metrics-) API
endpoint. Monitoring tools running locally can retrieve the same metrics using
the [`metrics`](https://docs.weblate.org/ja/latest/admin/management.md#weblate-admin-metrics) command.

#### SEE ALSO
* [Weblate が正しく設定されているかどうかを確認する方法は？](https://docs.weblate.org/ja/latest/faq.md#faq-monitoring)
* [Celery の状態の監視](#monitoring-celery)
* [Munin 用の Weblate プラグイン](https://github.com/WeblateOrg/munin)

<a id="collecting-errors"></a>

## エラーレポートの収集とパフォーマンスの監視

Weblate は、他のソフトウェアと同じようにエラーが発生することがあります。有用な障害状態を収集するには、サードパーティのサービスを使用して、そのような情報を収集してください。これは、Celery タスクが失敗した場合にとても便利です。失敗した場合、ログにエラーが報告されるだけで、メールで通知はされません。Weblate が対応するログ サービス:

### メールアドレス

Weblate のデフォルト設定では、[`django.utils.log.AdminEmailHandler`](https://docs.djangoproject.com/ja/stable/ref/logging/#django.utils.log.AdminEmailHandler) を通じて、サーバーエラー発生時に Django が管理者へメールを送信するよう設定されています。これは最も手軽に導入できる方法ですが、エラー通知メールには機密情報が含まれる可能性があるため、プライバシーの観点から他の手段の利用も検討すべきです。詳細については [セキュリティへの影響](https://docs.djangoproject.com/ja/stable/topics/logging/#logging-security-implications) を参照してください。

この動作を無効にするには、Weblate の設定で [`LOGGING`](https://docs.djangoproject.com/ja/stable/ref/settings/#std-setting-LOGGING) から `mail_admins` を削除するか、Docker 環境で [`WEBLATE_ADMIN_NOTIFY_ERROR`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_ADMIN_NOTIFY_ERROR) を無効にしてください。

### Sentry

Weblate には [Sentry](https://sentry.io/) への対応が組み込まれています。使用するには、 `settings.py` に [`SENTRY_DSN`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SENTRY_DSN) だけを設定すれば十分です。

```python
SENTRY_DSN = "https://id@your.sentry.example.com/"
```

Sentry は、Weblate のパフォーマンスを監視するためにも使用できます。特定の割合の操作のトレースとプロファイルを収集することで、パフォーマンスの問題を特定できます。これは、[`SENTRY_TRACES_SAMPLE_RATE`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SENTRY_TRACES_SAMPLE_RATE) および [`SENTRY_PROFILES_SAMPLE_RATE`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-SENTRY_PROFILES_SAMPLE_RATE) を使用して設定できます。

#### SEE ALSO
* [Sentry パフォーマンス監視](https://docs.sentry.io/product/sentry-basics/performance-monitoring/)
* [Sentry Profiling](https://docs.sentry.io/product/profiling/)

### Google Cloud Error Reporting

Weblate can report handled server errors to [Google Cloud Error Reporting](https://docs.cloud.google.com/error-reporting/docs/grouping-errors).
Install Weblate with the `google-errors` extra and configure
[`GOOGLE_CLOUD_ERROR_REPORTING`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-GOOGLE_CLOUD_ERROR_REPORTING) in `settings.py`:

```python
GOOGLE_CLOUD_ERROR_REPORTING = {
    "project": "your-google-cloud-project",
}
```

Weblate automatically reports errors under the `weblate` service and uses the
current Weblate version or Git revision as the reported version. These values
can be overridden by setting `service` or `version` in
[`GOOGLE_CLOUD_ERROR_REPORTING`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-GOOGLE_CLOUD_ERROR_REPORTING).

### OpenTelemetry

Weblate can export backend traces using [OpenTelemetry](https://opentelemetry.io/).
It uses OTLP over HTTP and can send traces to an OpenTelemetry Collector or a
compatible vendor endpoint.

```python
OPENTELEMETRY_ENABLED = True
OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT = "https://collector.example.com/v1/traces"
OPENTELEMETRY_TRACES_SAMPLE_RATE = 0.1
```

The integration traces Django requests, Celery tasks, Redis, outgoing HTTP
requests, database calls, and Weblate-specific spans. Configure it using
[`OPENTELEMETRY_ENABLED`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-OPENTELEMETRY_ENABLED),
[`OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT), and
[`OPENTELEMETRY_TRACES_SAMPLE_RATE`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-OPENTELEMETRY_TRACES_SAMPLE_RATE).

<a id="rollbar-errors"></a>

### Rollbar

Weblate は [Rollbar](https://rollbar.com/) に対応しています。使用方法は、 [Rollbar notifier for Python](https://docs.rollbar.com/docs/python/) の指示に従うだけです。

つまり、`settings.py` に必要な設定:

```python
# Add rollbar as last middleware:
MIDDLEWARE = [
    # … other middleware classes …
    "rollbar.contrib.django.middleware.RollbarNotifierMiddleware",
]

# Configure client access
ROLLBAR = {
    "access_token": "POST_SERVER_ITEM_ACCESS_TOKEN",
    "environment": "development" if DEBUG else "production",
    "branch": "main",
    "root": "/absolute/path/to/code/root",
}
```

他のすべてを自動的に連携して、サーバー側とクライアント側の両方のエラーを収集します。

#### NOTE
エラーログには、正常に処理された例外も含まれていますが、アップロードされたファイルの解析失敗などの問題を示唆するものかもしれません。

<a id="graylog"></a>

### Graylog によるログ管理

#### Versionadded
Added in version 5.9.

Weblate は GELF TCP プロトコルを使ったログ記録を設定できます。これは Graylog 統合のために開発されましたが、準拠する任意のロギングプラットフォームで利用可能です。

設定のひな形は [設定例](https://docs.weblate.org/ja/latest/admin/sample.md#sample-configuration) に含まれています。Docker を使用する場合は [`WEBLATE_LOG_GELF_HOST`](https://docs.weblate.org/ja/latest/admin/install/docker.md#envvar-WEBLATE_LOG_GELF_HOST) を用いて設定します。

## Weblate を別のサーバーに移行

Weblate を別のサーバーに移行するのは非常に簡単です。しかし、複数の場所にデータを保存しているので、慎重に移行してください。最良の方法は、移行のために Weblate を停止することです。

### データベースの移行

最も簡単な方法は、データベース純正の管理ツールを使用することです。これは通常もっとも効果的です（例: **pg_dump**）。また、データベースが対応している場合は、レプリケーションを使用できます。

#### SEE ALSO
[他のデータベースから PostgreSQL に移行](https://docs.weblate.org/ja/latest/admin/upgrade.md#database-migration) に説明があるデータベース間の移行。

### VCS リポジトリの移行

[`DATA_DIR`](https://docs.weblate.org/ja/latest/admin/config.md#std-setting-DATA_DIR) に保存されている VCS リポジトリーも必ず移行してください。単純にコピーすることも、**rsync** コマンドを使用して、より効率的に移行することもできます。

### その他の注意事項

Weblate が使用していた可能性のある Valkey、Redis、Cron ジョブ、カスタム認証バックエンドなどの他のサービスも移行することを忘れないでください。
