Linux(Ubuntu)にPHPをインストールする方法を解説します。
以下のコマンドを実行し、パッケージをアップデートします。
sudo apt update
![](https://ootkblog.com/wp-content/uploads/2024/04/linux-ubuntu-php-install-1.png)
以下のコマンドを実行し、PHPがインストールされているか確認します。
php -v
![](https://ootkblog.com/wp-content/uploads/2024/04/linux-ubuntu-php-install-2.png)
上記で表示された通りに、以下のコマンドを実行し、PHPをインストールします。
sudo apt install php8.1-cli
![](https://ootkblog.com/wp-content/uploads/2024/04/linux-ubuntu-php-install-3.png)
以下のコマンドを実行し、PHPがインストールされているか確認します。
php -v
![](https://ootkblog.com/wp-content/uploads/2024/04/linux-ubuntu-php-install-4.png)
これでLinux(Ubuntu)にPHPをインストール完了です。