Score:1

CentOS 7 - upgrade PHP version from 7.2 to 8

gb flag
  • 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)

Score:1
jp flag

/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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.