Ubuntu20.04にphp8.0.2をインストールする方法

1.osバージョンの確認
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04″
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

2. software-properties-commonをインストール
$ sudo apt-get install software-properties-common
[sudo] password for cftuser:
Reading package lists… Done

After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y

3.リポジトリを追加
$ sudo add-apt-repository ppa:ondrej/php

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.
ENTER

4.OSアップデート
$ sudo apt update

5.php8をインストール
$ sudo apt install php8.0 php8.0-intl php8.0-gd php8.0-mysql php8.0-sqlite3

Need to get 6,542 kB of archives.
After this operation, 29.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

6.phpバージョンの確認
$ php -v
PHP 8.0.2 (cli) (built: Feb 14 2021 14:21:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies

Ubuntu

Posted by arkgame