3、Rocky Linux 9.4 安装 PHP 8.3
本篇文章使用 Remi 源来安装 PHP。
1、更新软件包
$ sudo dnf upgrade --refresh -y
2、安装 PHP Remi 源
安装 EPEL 源
$ sudo dnf -y install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
安装 Remi 源
$ sudo dnf -y install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
$ sudo dnf -y install dnf-utils
3、验证安装的 Remi 源
$ dnf module list
Last metadata expiration check: 0:00:34 ago on Mon 17 Jun 2024 11:46:31 AM CST.
Rocky Linux 9 - AppStream
Name Stream Profiles Summary
mariadb 10.11 client, galera, server [d] MariaDB Module
maven 3.8 common [d] Java project management and project comprehension tool
nginx 1.22 common [d] nginx webserver
nginx 1.24 common [d] nginx webserver
nodejs 18 common [d], development, minimal, s2i Javascript runtime
nodejs 20 common [d], development, minimal, s2i Javascript runtime
php 8.1 common [d], devel, minimal PHP scripting language
php 8.2 common [d], devel, minimal PHP scripting language
postgresql 15 client, server [d] PostgreSQL server and client module
postgresql 16 client, server [d] PostgreSQL server and client module
redis 7 common [d] Redis persistent key-value database
ruby 3.1 common [d] An interpreter of object-oriented scripting language
ruby 3.3 common [d] An interpreter of object-oriented scripting language
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
composer 2 common [d] Dependency Manager for PHP
memcached remi common [d] High Performance, Distributed Memory Object Cache
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language
php remi-8.2 common [d], devel, minimal PHP scripting language
php remi-8.3 common [d], devel, minimal PHP scripting language
redis remi-5.0 common [d] Redis persistent key-value database
redis remi-6.0 common [d] Redis persistent key-value database
redis remi-6.2 common [d] Redis persistent key-value database
redis remi-7.0 common [d] Redis persistent key-value database
redis remi-7.2 common [d] Redis persistent key-value database
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
4、使用 Remi 源安装 PHP 8.3
查看版本
$ sudo dnf module list php
Last metadata expiration check: 0:04:13 ago on Mon 17 Jun 2024 11:46:31 AM CST.
Rocky Linux 9 - AppStream
Name Stream Profiles Summary
php 8.1 common [d], devel, minimal PHP scripting language
php 8.2 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language
php remi-8.2 common [d], devel, minimal PHP scripting language
php remi-8.3 common [d], devel, minimal PHP scripting language
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
启用安装 PHP 8.3
$ sudo dnf -y module enable php:remi-8.3
安装 PHP 8.3
$ sudo dnf -y install php
查看 PHP 版本
$ php -v
PHP 8.3.8 (cli) (built: Jun 4 2024 14:53:17) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.8, Copyright (c) Zend Technologies
with Zend OPcache v8.3.8, Copyright (c), by Zend Technologies
5、设置开机自启
$ sudo systemctl enable php-fpm.service
$ sudo systemctl start php-fpm.service
6、安装 PHP 扩展
1)安装扩展
$ sudo dnf -y install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache php-swoole
2)查询扩展
比如这里没有列出 Swoole 扩展,但是我们要安装该怎么办?查询扩展,然后进行安装。
$ sudo dnf search php83-php- | grep swoole
Last metadata expiration check: 0:14:49 ago on Mon 17 Jun 2024 11:46:31 AM CST.
php83-php-pecl-openswoole22-devel.x86_64 : php83-php-pecl-openswoole22 developer files (header)
php83-php-pecl-swoole5-devel.x86_64 : php83-php-pecl-swoole5 developer files (header)
php83-php-pecl-openswoole22.x86_64 : High Performance Programmatic Server for PHP with Async IO, Coroutines and Fibers
php83-php-pecl-swoole5.x86_64 : PHP's asynchronous concurrent distributed networking framework
7、安装 php-devel
如果后续需要使用 phpize
就需要安装它了
$ sudo dnf -y install php-devel
请登录后再评论