Nginx cannot change php version

OS type and version: CentOS Linux 8.4.2105
Webmin version: 1.981
Virtualmin version: 6.17
Related products version: RECOMMENDED

Hi, virtualmin install script with LEMP flag on centos 8 have php7.2 installed by default. I have created a virtual server. After installing php 7.4 as recommended here my virtual server does not change its php version to 7.4, even after I run yum remove php72.

Changing php version on virtualmin > server configuration > PHP options is not working, PHP script execution mode does not have FCGId nor FPM checked.

How to change my virtual server php version?

EDIT: part of phpinfo.php result

System Linux 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64
Build Date Oct 22 2019 08:28:36
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc
Loaded Configuration File /home/myserver/etc/php7.2/php.ini
Scan this dir for additional .ini files /etc/php.d
Additional .ini files parsed /etc/php.d/10-opcache.ini, /etc/php.d/20-bz2.ini, /etc/php.d/20-calendar.ini, /etc/php.d/20-ctype.ini, /etc/php.d/20-curl.ini, /etc/php.d/20-dom.ini, /etc/php.d/20-exif.ini, /etc/php.d/20-fileinfo.ini, /etc/php.d/20-ftp.ini, /etc/php.d/20-gd.ini, /etc/php.d/20-gettext.ini, /etc/php.d/20-iconv.ini, /etc/php.d/20-json.ini, /etc/php.d/20-mbstring.ini, /etc/php.d/20-mysqlnd.ini, /etc/php.d/20-odbc.ini, /etc/php.d/20-pdo.ini, /etc/php.d/20-phar.ini, /etc/php.d/20-posix.ini, /etc/php.d/20-shmop.ini, /etc/php.d/20-simplexml.ini, /etc/php.d/20-sockets.ini, /etc/php.d/20-sqlite3.ini, /etc/php.d/20-sysvmsg.ini, /etc/php.d/20-sysvsem.ini, /etc/php.d/20-sysvshm.ini, /etc/php.d/20-tokenizer.ini, /etc/php.d/20-xml.ini, /etc/php.d/20-xmlwriter.ini, /etc/php.d/20-xsl.ini, /etc/php.d/30-mysqli.ini, /etc/php.d/30-pdo_mysql.ini, /etc/php.d/30-pdo_odbc.ini, /etc/php.d/30-pdo_sqlite.ini, /etc/php.d/30-wddx.ini, /etc/php.d/30-xmlreader.ini, /etc/php.d/30-xmlrpc.ini, /etc/php.d/40-zip.ini
PHP API 20170718
PHP Extension 20170718
Zend Extension 320170718
Zend Extension Build API320170718,NTS
PHP Extension Build API20170718,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling enabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
IPv6 Support enabled
DTrace Support available, disabled
Registered PHP Streams https, ftps, compress.zlib, php, file, glob, data, http, ftp, zip, compress.bzip2, phar
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters zlib., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk, bzip2., convert.iconv.

After the install, did you click on System Settings → Re-Check Config and what does it detect?

It detects only php 7.4 version.

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active …

Your system has 3.64 GiB of memory, which is at or above the Virtualmin recommended minimum of 256 MiB.

BIND DNS server is installed, and the system is configured to use it.

Mail server Postfix is installed and configured.

Postfix is configured to support per-domain outgoing IP addresses.

The following PHP versions are available : 7.4.26 (/bin/php74-cgi)

The following PHP-FPM versions are available on this system : 7.4.19 (php-fpm) 7.4.26 (php74-php-fpm)

The following PHP execution modes are available : fcgid fpm

PHP versions have changed to 7.4 since last check. Regenerating any missing php.ini files.

Webalizer is installed.

MariaDB 10.3.28 is installed and running.

ProFTPD is installed.

Logrotate is installed.

SpamAssassin and Procmail are installed and configured for use.

Plugin AWstats reporting is installed OK.

Plugin Nginx website is installed OK.

Plugin Nginx SSL website is installed OK.

Using network interface eth0 for virtual IPs.

IPv6 addresses are available, using interface eth0.

It clearly detects two, though? (But you don’t have a php-cgi package installed for the 7.4.19 version, so it obviously cannot use that version for CGI and FCGI.)

You should be using php-fpm, unless you have a compelling reason to do otherwise.

You almost certainly shouldn’t uninstall the default php version. But, that’s not what you’re doing with this command…you’re not doing anything with this command, as there is no php72 package on a stock CentOS 8 system. But, even if you got the package names right, it’s not the right thing to do (you’d make a mess).

Oh, wait…now that I look closer, I think you have succeeded in removing the default PHP packages (that wasn’t the command that did it, though). The default version is 7.2.24 on my systems, but the package names are not php72*.

Our docs definitely don’t tell you to do that.

And, that explains why you can’t select things (though it’s a bug that it’s not letting you fix it). You removed the version Virtualmin had configured for your sites and now it’s confused…something outside of its understanding has happened.

So, two things:

  1. Use FPM. It’s the preferred/recommended execution mode for most deployments.
  2. Show us what php packages you have installed if you continue to have problems (rpm -qa|grep php).

It’s maybe possible that switching to FPM can sort things out. There is some kind of UI bug here, triggered by PHP versions that were in use being removed. But, I’m pretty sure you should be able to select a version that is available.

I cannot chose either FCGId nor FPM. No radio button checked, and after checking it, and save it, the radio button become not checked again.



































If this needed about yum module list php

[root@ns ~]# sudo yum module list php
Last metadata expiration check: 3:14:27 ago on Fri 19 Nov 2021 07:50:35 AM WIB.
CentOS Linux 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 [e]                                                                 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                                                                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                                                               

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@ns ~]# php -v
PHP 7.4.19 (cli) (built: May  4 2021 11:06:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies

I believe this is the command that removed it
dnf remove php72 php72-{build,php,php-cli,php-common,php-fpm,php-gd,php-geos,php-intl,php-json,php-mbstring,php-mcrypt,php-mysqlnd,php-opcache,php-pear,php-pecl-geoip,php-pecl-gnupg,php-pecl-http,php-pecl-http-devel,php-pecl-json-post,php-pecl-mysql,php-pecl-oauth,php-pecl-redis,php-pecl-stats,php-pecl-uploadprogress,php-pecl-uuid,php-pecl-varnish,php-pecl-zip,php-soap}

This is the list of commands that I run on the quest of changing PHP

dnf -y install && dnf clean all
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache,pecl-redis,pecl-varnish,soap}
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysql,opcache,pecl-redis,pecl-varnish,soap}
dnf -y remove php74-php-mysql
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache,pecl-redis,pecl-varnish,soap}

There are some command in between for making real cron script for all wordpress hosted in this vps, but it is not relevant here since it is only about cronjobs.

dnf remove php72 php72-{build,php,php-cli,php-common,php-fpm,php-gd,php-geos,php-intl,php-json,php-mbstring,php-mcrypt,php-mysqlnd,php-opcache,php-pear,php-pecl-geoip,php-pecl-gnupg,php-pecl-http,php-pecl-http-devel,php-pecl-json-post,php-pecl-mysql,php-pecl-oauth,php-pecl-redis,php-pecl-stats,php-pecl-uploadprogress,php-pecl-uuid,php-pecl-varnish,php-pecl-zip,php-soap}
php --version
sudo yum module list php
 sudo yum module enable php:remi-7.4
sudo yum module reset php
sudo yum module enable php:remi-7.4
sudo yum module list php
php -v
yum --enablerepo=remi-php74 install php
yum --enablerepo=remi-php7.4 install php
yum install php74
php -v sudo yum module reset php
sudo yum module enable php:7.4
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache,pecl-redis,pecl-varnish,soap}
dnf -y install php74 php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache,pecl-redis,pecl-varnish,soap}
php -v

I can return the enabled version back to centos appstream 7.2 if needed. Since I removed the default PHP installed from virtualmin script, should I install it again using this command?
dnf -y install php72-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

I have tried to install php 7.4 from remi repo. Should I change back to default? How can I do it?

It may be slightly corrupted. You have 2 versions of 7.4 - its fine to remove default 7.2 on a new server but it needs to be a clean uninstall before you change stream to 7.4, I use 7.4.26 and only FPM or disabled option enabled. Thats my choice and personal preference but I would recommend FPM.


One option is to remove both 7.4 versions completely. Disable 7.4.19 stream and re install 7.4.26 or back to 7.2

yum --enablerepo=remi-php74 install php
yum --enablerepo=remi-php7.4 install php

Thats your 2 versions. Disable the one you dont need. Make sure everything is removed before reinstalling version you want. yum remove “php-*” -y

Get one version working first then add a different version later as needed if this is required.

Assume you already have these repos:
sudo dnf install
sudo dnf install
sudo dnf install dnf-utils

See available PHP versions:
sudo dnf module list php

sudo dnf module install php:remi-7.4
sudo dnf install -y php-fpm php-cli php-common php-zip php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo
sudo systemctl enable php-fpm
sudo systemctl restart httpd

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.