Ubuntu環境にPHPレポジトリを追加してインストール

概要

UbuntuのLAMP環境に必要なPHP8.1系とその設定を行います。

さっくりとした手順

  1. レポジトリを追加します
  2. インストールを行います
  3. インストールを確認します

レポジトリを追加します。

sudo add-apt-repository ppa:ondrej/php

Ubuntu20.04系ではこれを行わないとPHP7.4系しかインストールされません。

sudo aptitude update

PHP8.1系のインストールを行います。

sudo aptitude install php8.1
sudo aptitude install php8.1-{opcache,pdo,bcmath,calendar,ctype,fileinfo,ftp,gd,intl,json,ldap,mbstring,mysql,posix,readline,sockets,bz2,tokenizer,zip,curl,iconv,phar,xml,dev,imagick,gmp}

インストール後の確認をします。

sudo systemctl restart apache2.service
php -v
PHP 8.1.27 (cli) (built: Dec 21 2023 20:19:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.27, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.27, Copyright (c), by Zend Technologies

Revision #1
Created 2 April 2024 11:22:29 by manualmaton
Updated 6 September 2024 14:19:22 by manualmaton