백엔드 개발 PHP8 가능한 한 빨리 php8.2 패키지를 설치하는 방법을 가르쳐주세요(ubuntu 20.04 focus)

가능한 한 빨리 php8.2 패키지를 설치하는 방법을 가르쳐주세요(ubuntu 20.04 focus)

Jan 13, 2023 am 10:03 AM
php8.2

이 기사에서는 php8.2에 대한 관련 지식을 제공합니다. 주로 php8.2 패키지를 빠르게 설치하는 방법을 소개하고 가르칩니다. 얼마나 빠른가요? 20분 정도 소요될 수 있으니... 한번 살펴보시고, 모두에게 도움이 되었으면 좋겠습니다.

php8.2 패키지의 빠른 설치(우분투 20.04 초점)

얼마나 빠르나요? 여기서 시도한 결과는 총 20분 정도입니다(운영 체제 제외).

또한 내 컴퓨터와 동일한 Alibaba Cloud 미러 라이브러리입니다. CentOS 시스템에 PHP를 포함한 다양한 소프트웨어를 설치하는 것은 매우 빠르지만 이 Ubuntu를 설치하는 것은 더 느립니다. (한 가지는 가능합니다. 이유는 Ubuntu가 사람이 너무 많기 때문에 Alibaba는 약간의 비용을 절약하기 위해 소스 다운로드 속도를 제한하기 때문입니다.

이 기사의 소프트웨어 버전

ubuntu 20.04
php 8.2.1
nginx 1.22.1
mysql 8.0.31
redis 7.0.7
git 2.24.4
로그인 후 복사

먼저 Alibaba의 Warehouse를 설치합니다

首先必须 apt update
安装 vim

vim /etc/apt/sources.list
内容如下,就是搞阿里云镜像。但是http的,被我改的。不搞无法更新。
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

然后
apt update

apt install -y --reinstall ca-certificates

现在,再把阿里云镜像库中的 http 改成标准的 https,
vim /etc/apt/sources.list

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
然后。再次
apt update
로그인 후 복사

php 8

apt install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils systemd gnupg2 lsb-release ubuntu-keyring

上面的命令需要选择多个选项。选亚洲 asia。选上海 shanghai

curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null

echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list


apt-get update

apt-get install -y php8.2-cli php8.2-dev  php8.2-pgsql php8.2-sqlite3 php8.2-gd  php8.2-curl  php8.2-imap php8.2-mysql php8.2-mbstring  php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap   php8.2-intl php8.2-readline  php8.2-ldap  php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole  php8.2-memcached php8.2-pcov  php8.2-fpm php8.2-gmp php8.2-imagick php8.2-mcrypt php8.2-uuid php8.2-yaml
로그인 후 복사

을 설치합니다. 위의 명령을 실행합니다. 대략 15분 정도 소요됩니다.

Alibaba의 작곡가 이미지 소스 설치

curl -o /usr/local/bin/composer https://mirrors.aliyun.com/composer/composer.phar

chmod +x /usr/local/bin/composer

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
로그인 후 복사

루트 ID를 사용하여 작곡가 명령을 실행하면 yes를 입력하라는 메시지가 표시됩니다. 꽤 번거로운 작업입니다. 그런 다음

vim /etc/environment
로그인 후 복사

text

export COMPOSER_ALLOW_SUPERUSER=1
로그인 후 복사

그런 다음

source /etc/environment
로그인 후 복사

nginx를 설치하고 통합합니다. php-fpm service

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx"  | tee /etc/apt/sources.list.d/nginx.list

apt update
apt install nginx

改php-fpm 配置。
sed -i 's/listen\ =\ \/run\/php\/php8.2-fpm.sock/listen\ =\ 127.0.0.1:9000/g' /etc/php/8.2/fpm/pool.d/www.conf


修改 /etc/nginx/nginx.conf
第一行 
user  www-data;

然后,
rm -f /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/default.conf 文件内容如下

server {
    listen       80;
    server_name  localhost;
    charset utf-8 ;
    access_log  /var/log/nginx/host.access.log  main;
    root   /usr/share/nginx/html;
    index index.php  index.html index.htm;
    error_page 404  500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
로그인 후 복사

다음과 같이 php 파일을 추가합니다.

vi /usr/share/nginx/html/1.php

<?php
phpinfo();
로그인 후 복사

php-fpm과 nginx를 시작하고 설치가 제대로 되었는지 확인합니다

/etc/init.d/nginx start
/etc/init.d/php8.2-fpm start

curl localhost/1.php
# 如果能看到很多的大量输出,说明php和nginx正确安装了。
로그인 후 복사

mysql 8을 설치합니다

apt install mysql-server-8.0 mysql-client-8.0



# 查看初始密码:
grep &#39;temporary password&#39; /var/log/mysqld.log

# 用查看到的密码进入mysql 的 shell
mysql -uroot -p
로그인 후 복사

전체 설정 과정은 다음과 같습니다. 먼저 초기화를 변경한 다음 새 사용자를 추가하고 이전 사용자를 승인한 다음 삭제하세요.

ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED WITH mysql_native_password BY &#39;tb4Wn3BthR.&#39;;
flush privileges;

create user &#39;root&#39;@&#39;%&#39; identified by &#39;root1234&#39;;
ALTER USER &#39;root&#39;@&#39;%&#39; IDENTIFIED WITH mysql_native_password BY &#39;root1234&#39;;
GRANT ALL PRIVILEGES ON *.* TO &#39;root&#39;@&#39;%&#39;;
drop user root@localhost;
flush privileges;
로그인 후 복사

쉘을 종료하고 다시 들어가세요.

이제 쉘에 직접 들어갈 수 있습니다

mysql -uroot -proot1234

# 这句话查看用户的加密方式。
select user, host, plugin from mysql.user\G;

# plugin: caching_sha2_password 表示老的MySQL客户端无法连接!
로그인 후 복사

redis 6 및 기타 일반적으로 사용되는 라이브러리를 설치하세요

지침: redis 7을 설치하려면 바이너리 패키지를 컴파일해야 하므로 컴파일하지 않았습니다.

curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list

apt-get update

apt-get install redis-stack-server
로그인 후 복사

위 버전과 다르다는 점 참고하세요. redis5를 설치하고 싶다면

redis5를 원한다면 소스가 필요하지 않습니다.

apt install redis-server
로그인 후 복사

요약

Alibaba Cloud에 감사드립니다. 미러 라이브러리이지만 속도가 너무 빠르지는 않습니다.

추천 학습: "PHP 비디오 튜토리얼"

위 내용은 가능한 한 빨리 php8.2 패키지를 설치하는 방법을 가르쳐주세요(ubuntu 20.04 focus)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)