大网数据广告活动
服务器运维问答

CentOS 7 - upgrade PHP version from 7.2 to 8

· 52CE 我爱测

CentOS 7 Nginx Current websites run on PHP 7.2 PHP -v says ```# php -v PHP 8.0.25 (cli) (built: Oct 25 2022 09:42:31) ( NTS gcc x86_64 ) Copyright (c) The PHP Group``` But phpinfo() in the nginx server shows: PHP Version 7.2.34 C…

问题原文

原帖链接 · TheUnreal · CC BY-SA 4.0

  • CentOS 7
  • Nginx
  • Current websites run on PHP 7.2

PHP -v says

```# php -v
PHP 8.0.25 (cli) (built: Oct 25 2022 09:42:31) ( NTS gcc x86_64 )
Copyright (c) The PHP Group```

But phpinfo() in the nginx server shows: PHP Version 7.2.34

Configuration File (php.ini) Path   /etc/opt/remi/php72
Loaded Configuration File   /etc/opt/remi/php72/php.ini

Nginx site config:

location ~ \.php$ {

               fastcgi_pass   127.0.0.1:9072;   #set port for php-fpm to listen on
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include         fastcgi_params;
                include /etc/nginx/fastcgi_params;


        }

How I can upgrade my PHP to 8? (Or, why it's not updating/changing in the website level)

已采纳解答

原帖链接 · Remi Collet · CC BY-SA 4.0

/etc/opt/remi/php72

Looks like you have installed multiple version of PHP.

fastcgi_pass 127.0.0.1:9072;

This is the listen socket defined in the FPM configuration file for PHP 7.2 (in /etc/opt/remi/php72/php-fpm.d)

Simply change this to the one defined in the FPM configuration file for PHP 8.0 (see /etc/php-fpm.d)

You have to start (if not yet used) the FPM 8.0 service (probably "php-fpm")

You can also stop (if not used anymore) the FPM 7.2 service (probably "php72-php-fpm").

If you don't need PHP 7.2 anymore you can also uninstall it

dnf remove 'php72*'

Reminders:

  • for a proper repository configuration, follow the wizard instruction
  • CentOS 7 is old and close to its end of life (June 2024), I recommend a modern version (EL-8 or EL-9) especially to run modern software such as PHP 8.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-10-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。