

AWS App Runner は、2026 年 4 月 30 日以降、新規のお客様に公開されなくなります。App Runner を使用する場合は、その日付より前にサインアップします。既存のお客様は、通常どおりサービスを引き続き使用できます。詳細については、「[AWS App Runner  可用性の変更](https://docs.aws.amazon.com/apprunner/latest/dg/apprunner-availability-change.html)」を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# PHP プラットフォームを使用する
<a name="service-source-code-php"></a>

**重要**  
App Runner は、2025 年 **12 月 31 日に PHP 8.**1 のサポートを終了します。推奨事項と詳細については、「」を参照してください[マネージドランタイムバージョンのサポート終了](service-source-code.md#service-source-code.managed-platforms.eos)。

 AWS App Runner PHP プラットフォームはマネージドランタイムを提供します。各ランタイムを使用して、PHP バージョンに基づいてウェブアプリケーションでコンテナを構築および実行できます。PHP ランタイムを使用すると、App Runner はマネージド PHP ランタイムイメージで始まります。このイメージは [Amazon Linux Docker イメージ](https://hub.docker.com/_/amazonlinux)に基づいており、PHP のバージョンと一部のツールのランタイムパッケージが含まれています。App Runner はこのマネージドランタイムイメージをベースイメージとして使用し、アプリケーションコードを追加して Docker イメージを構築します。次に、このイメージをデプロイして、コンテナでウェブサービスを実行します。

 App Runner コンソールまたは [CreateService](https://docs.aws.amazon.com/apprunner/latest/api/API_CreateService.html) API オペレーションを使用してサービス[を作成する](manage-create.md)ときに、App Runner サービスのランタイムを指定します。ソースコードの一部としてランタイムを指定することもできます。コードリポジトリに含める [App Runner 設定ファイル](config-file.md)で `runtime`キーワードを使用します。マネージドランタイムの命名規則は *<language-name><major-version>* です。

有効な PHP ランタイム名とバージョンについては、「」を参照してください[PHP ランタイムリリース情報](service-source-code-php-releases.md)。

App Runner は、デプロイまたはサービスの更新ごとに、サービスのランタイムを最新バージョンに更新します。アプリケーションで特定のバージョンのマネージドランタイムが必要な場合は、[App Runner 設定ファイルの](config-file.md) `runtime-version`キーワードを使用して指定できます。メジャーバージョンやマイナーバージョンなど、任意のレベルのバージョンにロックできます。App Runner は、サービスのランタイムに対してのみ低レベルの更新を行います。

PHP ランタイムのバージョン構文: `major[.minor[.patch]]`

例: `8.1.10`

バージョンロックの例を次に示します。
+ `8.1` – メジャーバージョンとマイナーバージョンをロックします。App Runner はパッチバージョンのみを更新します。
+ `8.1.10` – 特定のパッチバージョンにロックします。App Runner はランタイムバージョンを更新しません。

**重要**  
  デフォルトのリポジトリルート[ディレクトリ以外の場所で App Runner サービスのコードリポジトリソース](service-source-code.md#service-source-code.source-directory)ディレクトリを指定する場合は、PHP マネージドランタイムバージョンが PHP `8.1.22`以降である必要があります。より前の PHP ランタイムバージョン`8.1.22`では、デフォルトのルートソースディレクトリのみを使用できます。 

**Topics**
+ [PHP ランタイム設定](#service-source-code-php.config)
+ [互換性](#service-source-code-php.compatibility)
+ [PHP ランタイムの例](#service-source-code-php.examples)
+ [PHP ランタイムリリース情報](service-source-code-php-releases.md)

## PHP ランタイム設定
<a name="service-source-code-php.config"></a>

マネージドランタイムを選択する場合は、少なくとも コマンドを構築して実行するように設定する必要があります。App Runner サービス[を作成](manage-create.md)または[更新](manage-configure.md)するときに設定します。これを行うには、次のいずれかの方法を使用します。
+ **App Runner コンソールの使用** – 作成プロセスまたは設定タブの**ビルドの設定**セクションでコマンドを指定します。
+ **App Runner API の使用** – [CreateService](https://docs.aws.amazon.com/apprunner/latest/api/API_CreateService.html) または [UpdateService](https://docs.aws.amazon.com/apprunner/latest/api/API_UpdateService.html) API オペレーションを呼び出します。[CodeConfigurationValues](https://docs.aws.amazon.com/apprunner/latest/api/API_CodeConfigurationValues.html) データ型の `BuildCommand`および `StartCommand`メンバーを使用してコマンドを指定します。
+ **[設定ファイル](config-file.md)の使用** – 最大 3 つのビルドフェーズで 1 つ以上のビルドコマンドと、アプリケーションを起動する 1 つの実行コマンドを指定します。追加のオプションの設定があります。

設定ファイルの提供はオプションです。コンソールまたは API を使用して App Runner サービスを作成する場合、App Runner が作成時に設定を直接取得するか、設定ファイルから取得するかを指定します。

## 互換性
<a name="service-source-code-php.compatibility"></a>

次のいずれかのウェブサーバーを使用して、PHP プラットフォームで App Runner サービスを実行できます。
+ Apache HTTP Server
+ NGINX

Apache HTTP Server および NGINXは PHP-FPM と互換性があります。*Apache HTTP Server* と は、次のいずれか*NGINX*を使用して開始できます。
+ [スーパーバイザー - の実行の詳細については、](http://supervisord.org/introduction.html#supervisor-components/)[「スーパーバイザーの実行](http://supervisord.org/running.html#running-supervisord)」を参照してください。 *supervisord*
+ 起動スクリプト 

*Apache HTTP Server *または *NGINX* を使用して PHP プラットフォームで App Runner サービスを設定する方法の例については、「」を参照してください[PHP アプリケーションソースを完了する](#service-source-code-php.examples.end2end)。

### ファイル構造
<a name="service-source-code-php.compatibility.file-structure"></a>

は、ウェブサーバーの `root` ディレクトリの `public`フォルダにインストール`index.php`する必要があります。

**注記**  
`startup.sh` または `supervisord.conf`ファイルは、ウェブサーバーのルートディレクトリに保存することをお勧めします。`start` コマンドが `startup.sh`または `supervisord.conf`ファイルが保存されている場所を指していることを確認します。

 を使用している場合のファイル構造の例を次に示します*supervisord*。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ supervisord.conf
```

*スタートアップスクリプト*を使用している場合のファイル構造の例を次に示します。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ startup.sh
```

これらのファイル構造は、App Runner サービス用に指定されたコードリポジトリの[ソースディレクトリ](service-source-code.md#service-source-code.source-directory)に保存することをお勧めします。

```
/<sourceDirectory>/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ startup.sh
```

**重要**  
  デフォルトのリポジトリルート[ディレクトリ以外の場所で App Runner サービスのコードリポジトリソース](service-source-code.md#service-source-code.source-directory)ディレクトリを指定する場合、PHP マネージドランタイムバージョンは PHP `8.1.22`以降である必要があります。より前の PHP ランタイムバージョン`8.1.22`では、デフォルトのルートソースディレクトリのみを使用できます。   
App Runner は、デプロイまたはサービスの更新ごとに、サービスのランタイムを最新バージョンに更新します。[App Runner 設定ファイルの](config-file.md) `runtime-version`キーワードを使用してバージョンロックを指定しない限り、サービスはデフォルトで最新のランタイムを使用します。

## PHP ランタイムの例
<a name="service-source-code-php.examples"></a>

PHP サービスの構築と実行に使用される App Runner 設定ファイルの例を次に示します。

### 最小 PHP 設定ファイル
<a name="service-source-code-php.examples.minimal"></a>

次の例は、PHP マネージドランタイムで使用できる最小限の設定ファイルです。最小設定ファイルの詳細については、「」を参照してください[設定ファイルの例](config-file-examples.md#config-file-examples.managed)。

**Example apprunner.yaml**  

```
version: 1.0 
runtime: php81
build:
  commands:
    build:
      - echo example build command for PHP
run:
  command: ./startup.sh
```

### 拡張 PHP 設定ファイル
<a name="service-source-code-php.examples.extended"></a>

次の例では、PHP マネージドランタイムですべての設定キーを使用します。

**注記**  
これらの例で使用されるランタイムバージョンは *8.1.10* です。使用するバージョンに置き換えることができます。サポートされている最新の PHP ランタイムバージョンについては、「」を参照してください[PHP ランタイムリリース情報](service-source-code-php-releases.md)。

**Example apprunner.yaml**  

```
version: 1.0
runtime: php81
build:
  commands:
     pre-build:
      - scripts/prebuild.sh
    build:
      - echo example build command for PHP
    post-build:
      - scripts/postbuild.sh
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
run:
  runtime-version: 8.1.10
  command: ./startup.sh
  network:
    port: 5000
    env: APP_PORT
  env:
    - name: MY_VAR_EXAMPLE
      value: "example"
```

### PHP アプリケーションソースを完了する
<a name="service-source-code-php.examples.end2end"></a>

次の例は、 *Apache HTTP Server*または を使用して PHP ランタイムサービスにデプロイするために使用できる PHP アプリケーションのソースコードです*NGINX*。これらの例では、デフォルトのファイル構造を使用することを前提としています。

#### Apache HTTP Server を使用して で PHP プラットフォームを実行する supervisord
<a name="service-source-code-php.examples.end2end.appache-supervisord"></a>

**Example ファイル構造**  
+ `supervisord.conf` ファイルはリポジトリのどこにでも保存できます。`start` コマンドが`supervisord.conf`ファイルの保存先を指していることを確認します。
+ は、 `root` ディレクトリの `public`フォルダにインストール`index.php`する必要があります。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ supervisord.conf
```

**Example supervisord.conf**  

```
[supervisord]
nodaemon=true

[program:httpd]
command=httpd -DFOREGROUND
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm -F
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
```

**Example apprunner.yaml**  

```
version: 1.0
runtime: php81
build:
  commands:
    build:
      - PYTHON=python2 amazon-linux-extras install epel
      - yum -y install supervisor
run:
  command: supervisord
  network:
    port: 8080
    env: APP_PORT
```

**Example index.php**  

```
<html>
<head> <title>First PHP App</title> </head>
<body>
<?php
    print("Hello World!");
    print("<br>");
?>
</body>
</html>
```

#### Apache HTTP Server を使用して で PHP プラットフォームを実行する startup script
<a name="service-source-code-php.examples.end2end.appache-startupscript"></a>

**Example ファイル構造**  
+ `startup.sh` ファイルはリポジトリのどこにでも保存できます。`start` コマンドが`startup.sh`ファイルの保存先を指していることを確認します。
+ は、 `root` ディレクトリの `public`フォルダにインストール`index.php`する必要があります。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ startup.sh
```

**Example startup.sh**  

```
#!/bin/bash

set -o monitor

trap exit SIGCHLD

# Start apache
httpd -DFOREGROUND &

# Start php-fpm
php-fpm -F &

wait
```

**注記**  
Git リポジトリにコミットする前に、`startup.sh`ファイルを実行可能ファイルとして保存してください。を使用して`chmod +x startup.sh`、 `startup.sh` ファイルに実行アクセス許可を設定します。
`startup.sh` ファイルを実行可能ファイルとして保存しない場合は、`apprunner.yaml`ファイルに `build` コマンド`chmod +x startup.sh`として と入力します。

**Example apprunner.yaml**  

```
version: 1.0
runtime: php81
build:
  commands:
    build:
      - echo example build command for PHP
run:
  command: ./startup.sh
  network:
    port: 8080
    env: APP_PORT
```

**Example index.php**  

```
<html>
<head> <title>First PHP App</title> </head>
<body>
<?php
    print("Hello World!");
    print("<br>");
?>
</body>
</html>
```

#### NGINX を使用して で PHP プラットフォームを実行する supervisord
<a name="service-source-code-php.examples.end2end.nginx-supervisord"></a>

**Example ファイル構造**  
+ `supervisord.conf` ファイルはリポジトリのどこにでも保存できます。`start` コマンドが`supervisord.conf`ファイルの保存先を指していることを確認します。
+ は、 `root` ディレクトリの `public`フォルダにインストール`index.php`する必要があります。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ supervisord.conf
```

**Example supervisord.conf**  

```
[supervisord]
nodaemon=true

[program:nginx]
command=nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm -F
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
```

**Example apprunner.yaml**  

```
version: 1.0
runtime: php81
build:
  commands:
    build:
      - PYTHON=python2 amazon-linux-extras install epel
      - yum -y install supervisor
run:
  command: supervisord
  network:
    port: 8080
    env: APP_PORT
```

**Example index.php**  

```
<html>
<head> <title>First PHP App</title> </head>
<body>
<?php
    print("Hello World!");
    print("<br>");
?>
</body>
</html>
```

#### NGINX を使用した PHP プラットフォームの実行 startup script
<a name="service-source-code-php.examples.end2end.nginx-startupscript"></a>

**Example ファイル構造**  
+ `startup.sh` ファイルはリポジトリのどこにでも保存できます。`start` コマンドが`startup.sh`ファイルの保存先を指していることを確認します。
+ は、 `root` ディレクトリの `public`フォルダにインストール`index.php`する必要があります。

```
/
├─ public/
│  ├─ index.php
├─ apprunner.yaml
├─ startup.sh
```

**Example startup.sh**  

```
#!/bin/bash

set -o monitor

trap exit SIGCHLD

# Start nginx 
nginx -g 'daemon off;' &

# Start php-fpm
php-fpm -F &

wait
```

**注記**  
Git リポジトリにコミットする前に、`startup.sh`ファイルを実行可能ファイルとして保存してください。を使用して`chmod +x startup.sh`、 `startup.sh` ファイルに実行アクセス許可を設定します。
`startup.sh` ファイルを実行可能ファイルとして保存しない場合は、`apprunner.yaml`ファイルに `build` コマンド`chmod +x startup.sh`として と入力します。

**Example apprunner.yaml**  

```
version: 1.0
runtime: php81
build:
  commands:
    build:
      - echo example build command for PHP
run:
  command: ./startup.sh
  network:
    port: 8080
    env: APP_PORT
```

**Example index.php**  

```
<html>
<head> <title>First PHP App</title> </head>
<body>
<?php
    print("Hello World!");
    print("<br>");
?>
</body>
</html>
```

# PHP ランタイムリリース情報
<a name="service-source-code-php-releases"></a>

**重要**  
App Runner は、2025 年 **12 月 31 日に PHP 8.**1 のサポートを終了します。推奨事項と詳細については、「」を参照してください[マネージドランタイムバージョンのサポート終了](service-source-code.md#service-source-code.managed-platforms.eos)。

このトピックでは、App Runner がサポートする PHP ランタイムバージョンの詳細を一覧表示します。


**サポートされているランタイムバージョン — 元の App Runner ビルド**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/apprunner/latest/dg/service-source-code-php-releases.html)

**注記**  
App Runner は、最近リリースされた特定のメジャーランタイムのビルドプロセスを改訂しました。このため、このドキュメントの特定のセクションには、*改訂された App Runner ビルド*と*元の App Runner ビルド*への参照が表示されます。詳細については、「[マネージドランタイムバージョンと App Runner ビルド](service-source-code.md#service-source-code.build-detail)」を参照してください。