---
title: Web ビルド用の Apache サーバー設定
product: Unity Editor
version: '6000.0'
latest_version: '7000.0'
status: This page documents version 6000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/ja-jp/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-apache
latest_url: https://docs.unity.com/ja-jp/engine/7000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-apache.md
last_updated: 2026-09-14
generated_at: 2026-11-09T12:59:01.435Z
locale: ja-jp
---

# Web ビルド用の Apache サーバー設定

> Instructions on how to set up your Apache server for your Web build.

Unity Web ビルドで Apache サーバーを使用するように、Apache サーバー設定ファイルを設定します。

Apache はオープンソースのクロスプラットフォームウェブサーバーで、Unity Web で作成するアプリケーションに使用できます。

Apache の詳細とインストールおよび使用方法については、[Apache のドキュメント](https://httpd.apache.org/docs/) を参照してください。

## Apache Web ビルド方法の選択##choose-your-apache-web-build-method

Apache で Web ビルドを設定するには、以下の 2 つの方法のいずれかを使用します。

* `httpd.conf` の仮想ホスト

* `.htaccess` の仮想ホスト

推奨されるベストプラクティスは、Apache の `httpd.conf` の仮想ホストを設定することです (その設定にアクセスできる場合)。

### `httpd.conf` の仮想ホストによる方法の使用##use-the-virtual-host-in-httpd.conf-method

`httpd.conf` の仮想ホストによる方法を使用して Web ビルドを設定するには、Apache サーバー設定で以下のコードを使用します。

```apacheconf
<Directory /var/www/html/root/path/to/your/unity/content/>
<IfModule mod_mime.c>
RemoveType .gz
AddEncoding gzip .gz
# The correct MIME type for .data.gz would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it is preferable to use MIME Type application/gzip instead.##the-correct-mime-type-for-.data.gz-would-be-application/octet-stream-but-due-to-safari-bug-https://bugs.webkit.org/show_bug.cgi?id=247421-it-is-preferable-to-use-mime-type-application/gzip-instead.
#AddType application/octet-stream .data.gz
AddType application/gzip .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

RemoveType .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br

# Insert additional code here##insert-additional-code-here

</IfModule>
</Directory>
```

### `.htaccess` の仮想ホストによる方法の使用##use-the-virtual-host-in-.htaccess-method

例えば、ウェブホスティングの管理者権限がないなどの理由で `httpd.conf` を変更できないが、Apache で `.htaccess` がサポートされている場合は、以下の方法で `.htaccess` を設定できます。

```apacheconf
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.##note:-mod_mime-apache-module-must-be-enabled-for-this-configuration-to-work.
<IfModule mod_mime.c>

# The following lines are required for builds without decompression fallback, compressed with gzip##the-following-lines-are-required-for-builds-without-decompression-fallback-compressed-with-gzip
RemoveType .gz
AddEncoding gzip .gz
AddType application/gzip .data.gz # The correct MIME type here would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it's preferable to use MIME Type application/gzip instead.
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

# The following lines are required for builds without decompression fallback, compressed with Brotli##the-following-lines-are-required-for-builds-without-decompression-fallback-compressed-with-brotli
RemoveType .br
RemoveLanguage .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br

# The following line improves loading performance for uncompressed builds##the-following-line-improves-loading-performance-for-uncompressed-builds
AddType application/wasm .wasm

# Insert additional code here##insert-additional-code-here

</IfModule>
```

## gzip 圧縮されたビルドのパフォーマンス向上##improve-performance-for-gzip-compressed-builds

解凍フォールバックを使用して gzip 圧縮された Web ビルドのロードパフォーマンスを向上させるには、コードに以下の行を追加します。

```
AddEncoding gzip .unityweb
```

## 解凍フォールバックによる Brotli 圧縮されたビルドのパフォーマンス向上##improve-performance-for-brotli-compressed-builds-with-decompression-fallback

解凍フォールバックを使用して Brotli 圧縮されたビルドのロードパフォーマンスを向上させるには、設定に以下のコード行を追加します。

```
 AddEncoding br .unityweb
```

## Enable native C/C++ multithreading##enable-native-c/c++-multithreading

[**Player** 設定](/engine/6000.0/manual/platform-specific/webgl/develop/class-player-settings-web-gl.md) で **Enable Native C/C++ Multithreading** を有効にしてビルドを作成した場合は、以下のコードを設定ファイルに追加します。

```
 <FilesMatch "\.(htm|html|js|js.gz|js.br)$">
     Header add Cross-Origin-Opener-Policy "same-origin"
     Header add Cross-Origin-Embedder-Policy "require-corp"
     Header add Cross-Origin-Resource-Policy "cross-origin"
 </FilesMatch>
```

## オリジン間リソース共有 (CORS) リクエストの許可##allow-cross-origin-resource-sharing-(cors)-requests

オリジン間リソース共有 (CORS) リクエストを許可するには、以下のコードを設定に追加します。

```
 Header add Access-Control-Allow-Origin "*"
```

## 追加リソース##additional-resources

* [圧縮されたビルドとサーバーの設定](/engine/6000.0/manual/platform-specific/webgl/building-distribution/deploying.md)
* [サーバー設定コードサンプル](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples.md)
* [Web ビルド用の IIS サーバー設定](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-iis.md)
* [Web ビルド用の Nginx サーバー設定](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-nginx.md)
* [Web ビルド用の Node.js サーバー設定](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-nodejs.md)
