検証のために必要となったので WSL 上の Ubuntu に PHP をインストールしようとしたところ 404 Not Found と言われてしまいインストールができなかった。
$ sudo apt install php7.2-cli
Reading package lists... Done
(省略)
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsodium23 amd64 1.0.16-2 [143 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 php-common all 1:60ubuntu1 [12.1 kB]
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-common amd64 7.2.24-0ubuntu0.18.04.3
Ign:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-json amd64 7.2.24-0ubuntu0.18.04.3
Ign:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-opcache amd64 7.2.24-0ubuntu0.18.04.3
Ign:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-readline amd64 7.2.24-0ubuntu0.18.04.3
Err:3 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-common amd64 7.2.24-0ubuntu0.18.04.3
404 Not Found [IP: 2001:67c:1562::18 80]
Ign:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-cli amd64 7.2.24-0ubuntu0.18.04.3
Err:4 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-json amd64 7.2.24-0ubuntu0.18.04.3
404 Not Found [IP: 2001:67c:1562::18 80]
Err:5 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-opcache amd64 7.2.24-0ubuntu0.18.04.3
404 Not Found [IP: 2001:67c:1562::18 80]
Err:6 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-readline amd64 7.2.24-0ubuntu0.18.04.3
404 Not Found [IP: 2001:67c:1562::18 80]
Err:7 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 php7.2-cli amd64 7.2.24-0ubuntu0.18.04.3
404 Not Found [IP: 2001:67c:1562::18 80]
Fetched 155 kB in 4s (39.4 kB/s)
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-common_7.2.24-0ubuntu0.18.04.3_amd64.deb 404 Not Found [IP: 2001:67c:1562::18 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-json_7.2.24-0ubuntu0.18.04.3_amd64.deb 404 Not Found [IP: 2001:67c:1562::18 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-opcache_7.2.24-0ubuntu0.18.04.3_amd64.deb 404 Not Found [IP: 2001:67c:1562::18 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-readline_7.2.24-0ubuntu0.18.04.3_amd64.deb 404 Not Found [IP: 2001:67c:1562::18 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php7.2/php7.2-cli_7.2.24-0ubuntu0.18.04.3_amd64.deb 404 Not Found [IP: 2001:67c:1562::18 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
こういう場合は apt update コマンドを実行してリポジトリの一覧を更新すると良い。
$ sudo apt update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Get:2 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
(省略)
Fetched 4857 kB in 14s (357 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
203 packages can be upgraded. Run 'apt list --upgradable' to see them.
apt update 後に再度 apt install を実行するとインストールできると思う。
$ sudo apt install php7.2-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libsodium23 php-common php7.2-common php7.2-json php7.2-opcache php7.2-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libsodium23 php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
0 upgraded, 7 newly installed, 0 to remove and 203 not upgraded.
Need to get 2492 kB/2647 kB of archives.
After this operation, 12.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(省略)
Creating config file /etc/php/7.2/mods-available/opcache.ini with new version
Setting up php7.2-cli (7.2.24-0ubuntu0.18.04.4) ...
(省略)
インストールできたら実行してみる。
$ php --version
PHP 7.2.24-0ubuntu0.18.04.4 (cli) (built: Apr 8 2020 15:45:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.4, Copyright (c) 1999-2018, by Zend Technologies
多少古いバージョンだが正常に入ったようだ。
最新版(現時点では7.4系)をインストールするのであれば以下の記事のようにリポジトリを追加してからインストールしよう。
Ubuntu 18.04 に PHP 7.4 をインストールする | Lonely Mobiler
コメント