우분투 (WSL2)에 PHP8 설치

우분투 (WSL2)에 PHP8 설치

2022-10-06 last update

7 minutes reading PHP Windows 우분투 PHP8 우분투20.04

소개



안녕하세요. GutHub에서 관리하는 직무 경력서가 정기적으로 clone 된 필자입니다.

새로운 PC를 설치하고 PHP를 설치하고 싶지만 모처럼이므로 최신 PHP8을 설치하려고합니다.

절차



1. software-properties-common 설치



외부 리포지토리를 사용하려면 리포지토리 관리에 필요한 software-properties-common을 설치합니다.
$ sudo apt install software-properties-common

2. 리포지토리 추가



ppa:ondrej/php 리포지토리를 apt에 등록합니다.
$ sudo apt-add-repository ppa:ondrej/php

↓ 이런 것이 나옵니다만, 계속한다면 Enter 눌러라고 되어 있으므로 Enter 눌러 주세요.
 Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# 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.

3. apt update



리포지토리를 추가하면 apt update합시다!
$ sudo apt update

4. 만약을 위해 PHP8이 있는지 확인


$ sudo apt show php8.0

↓ 이런 것이 나오면 괜찮습니다
Package: php8.0
Version: 8.0.3-1+ubuntu20.04.1+deb.sury.org+1
Priority: optional
Section: php
Maintainer: Debian PHP Maintainers <[email protected]>
Installed-Size: 59.4 kB
Provides: php
Depends: libapache2-mod-php8.0 | php8.0-fpm | php8.0-cgi, php8.0-common
Download-Size: 24.3 kB
APT-Sources: http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
Description: server-side, HTML-embedded scripting language (metapackage)
 This package is a metapackage that, when installed, guarantees that you
 have at least one of the four server-side versions of the PHP interpreter
 installed. Removing this package won't remove PHP from your system, however
 it may remove other packages that depend on this one.
 .
 PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
 open source general-purpose scripting language that is especially suited
 for web development and can be embedded into HTML.

5. 막상 설치


$ sudo apt install php8.0 -y

6. 버전 확인


$ php -v

↓ 제대로 PHP8을 설치할 수있었습니다
PHP 8.0.3 (cli) (built: Mar  5 2021 07:54:13) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies

결론



새로운 졸업생에 들어간 회사는 소스에서 빌드하고 있다고 말했지만, apt 나 yum (더 이상 사용되지 않았습니다. ..)로 넣을 수 있다는 것이 편리합니다.

아, 빨리 PHP8의 Nullsafe Operator의 혜택을 받고 싶다! !

그럼!