LoginSignup
0
0

More than 1 year has passed since last update.

Ubuntu22.04にPHPをバージョンを指定してインストール

Last updated at Posted at 2022-11-12

2022.11.12現在

環境

  1. Ubuntu22.04

この記事ではUbuntu22.04でPHP7.4(を含めた過去バージョン)のインストール方法を示します。

PHPのインストール

通常版

cmd
$ sudo apt install -y php

有無を言わさずPHP8.1がインストールされます。

バージョン指定版

バージョン7.4の存在確認

cmd
$ sudo apt search php7.4
libapache2-mod-php7.4/jammy-updates,jammy-security 8.1.2-1ubuntu2.8 amd64
  Transitional package

何かヒットしますがPHP7.4本体ではない模様

リポジトリを追加

Ubuntu22.04の標準リポジトリにはPHP7.4がない為、PHP7.4を持っているリポジトリを追加

cmd
$ sudo add-apt-repository ppa:ondrej/php
   :
Press [ENTER] to continue or Ctrl-c to cancel.
# エンター押下

再びバージョン7.4の存在確認

cmd
$ sudo apt search php7.4
php7.4/jammy 1:7.4.33-1+ubuntu22.04.1+deb.sury.org+1 all
  server-side, HTML-embedded scripting language (metapackage)

PHP7.4がある

PHP7.4をインストール

cmd
$ sudo apt install -y php7.4

おまけ

リポジトリを削除

リポジトリを追加したけど目的のバージョンがなかった時に原点復帰したい

cmd
$ sudo add-apt-repository --remove ppa:ondrej/php
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0