PHPのバージョンアップ

Table of Content

PHP7.4からPHP8.1にバージョンアップ

利用できるPHPのバージョンを確認

[root@scct08 ~]# dnf module list php
AlmaLinux 8 - AppStream
Name    Stream         Profiles                         Summary
php     7.2 [d]        common [d], devel, minimal       PHP scripting language
php     7.3            common [d], devel, minimal       PHP scripting language
php     7.4            common [d], devel, minimal       PHP scripting language
php     8.0            common [d], devel, minimal       PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name    Stream         Profiles                         Summary
php     remi-7.2       common [d], devel, minimal       PHP scripting language
php     remi-7.3       common [d], devel, minimal       PHP scripting language
php     remi-7.4 [e]   common [d] [i], 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とApacheの停止

[root@scct08 ~]# systemctl stop php-fpm
[root@scct08 ~]# systemctl stop httpd

PHPのリセット

[root@scct08 ~]# dnf module reset php

PHPのインストールするバージョンを指定

[root@scct08 ~]# dnf module enable php:remi-8.1

PHPのアップデート

[root@scct08 ~]# dnf module -y update php:remi-8.1

エラーが発生したのでsmbclientを再インストール

PHP Warning:  PHP Startup: Unable to load dynamic library 'smbclient.so' (tried: /usr/lib64/php/modules/smbclient.so (/usr/lib64/php/modules/smbclient.so: undefined symbol: PHP_SHA1Init), /usr/lib64/php/modules/smbclient.so.so (/usr/lib64/php/modules/smbclient.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[root@scct08 ~]# pecl uninstall smbclient
[root@scct08 ~]# pecl install smbclient

PHPの起動と状態確認

[root@scct08 ~]# systemctl restart php-fpm
[root@scct08 ~]# systemctl status php-fpm

PHPの自動起動化

[root@scct08 ~]# systemctl enable php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@scct08 ~]# systemctl is-enabled php-fpm
enabled

Apacheの起動

[root@scct08 ~]# systemctl restart httpd

動作確認

[root@scct08 ~]# php -v
PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies
# vi /var/www/status/phpinfo.php
----------------------------------------
<?php phpinfo(); ?>
----------------------------------------

http://www.chinaz.org/status/phpinfo.php
file

参考URL

CentOS 8に構築したPHPのバージョンアップ | Studio ilia – スタジオ イリア

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です