「Windows10 に Linux 環境(wsl2)」で入れた WSL2 に Apache と PHP を入れます。今必要としているのは PHP だけですが、いずれ必要になりますので Apache も入れておきます。WordPress でもテストすることになればデータベースも必要になります。
01Apache のインストール
WSL2 上の Ubuntu を立ち上げ、ローカルソフトウェアパッケージを最新の状態にし、続いて Apache をインストールします。
$ sudo apt update $ sudo apt install apache2

Apache 2.4.41 が入りました。Apache を起動し http://localhost
にアクセスして確認します。
$ sudo service apache2 start

Apache2 が入りました。
02PHP のインストール
とりあえず本体のみインストールします。
$ sudo apt install php


PHP7.4.3 が入りました。phpinfo で確認します。
ドキュメントルート /var/www/html
に phpinfo.php などの名の以下のファイルをつくり、Apache を再起動して http://localhost/phpinfo.php
にアクセスします。
<?php phpinfo(); ?>


PHP が入りました。