How to determine the version of PHP running per site on a Virtualmin server

Find Virtualmin PHP versions for all websites

Method 1 – virtualmin command line

The command to list everything is here, but you’d want to use the shell script below it to filter just by name and PHP version
virtualmin list-domains --multiline

List only name and PHP version:

cat which-php.sh
virtualmin list-domains --multiline | awk '
/^[^[:space:]]/ {
    if (domain != "") {
        printf "%s %s\n", domain, (php != "" ? php : "-")
    }
    domain = $0
    php = ""
}
/^[[:space:]]+PHP version:/ {
    php = $NF
}
END {
    if (domain != "") {
        printf "%s %s\n", domain, (php != "" ? php : "-")
    }
}'

Method 2 – scan for php.ini files

The command provides an alternative method by scanning which php.ini versions are lying around in your site directories:

find -L /home/*/etc/php.ini -xtype l -exec ls -l {} \;

Updating the PHP version

You may use the command below to update a site to a new PHP version. It’s also fine to try and update a site which doesn’t have PHP (a website) installed, because it will simply error with `Virtual server example2.com does not have a web site enabled`

virtualmin modify-web --domain example.com --php-version 8.4

If you want to upgrade all your websites on the server to PHP 8.4, do this:

virtualmin list-domains --name-only | while read -r d; do virtualmin modify-web --domain "$d" --php-version 8.4; done

Setting all to FPM

Keep up with the times.

for domain in $(virtualmin list-domains –name-only); virtualmin modify-web –domain “$domain” –mode fpm; done

Turning of PHP logging for all

Consistency for all and exception handling when needed.

for domain in $(virtualmin list-domains –name-only); virtualmin modify-web –domain “$domain” –no-php-log; done

Checking for fcgid sites

You probably want to just use FPM and have a more consistent system.

# grep -r fcgid /etc/webmin/virtual-server/
/etc/webmin/virtual-server/domains/157009083923628:php_mode=fcgid
/etc/webmin/virtual-server/domains/156986181552631:php_mode=fcgid

Now cat those sites to see who they are. Better change ’em too.

Questions

Can you update the PHP version of disabled sites?

Yes

How do you purge the PHP 7.4 version?

First find all installed versions:

dpkg -l | grep '^ii' | grep '^ii  php7.4'
dpkg -l | grep '^ii' | grep '^ii  php8.0'
dpkg -l | grep '^ii' | grep '^ii  php8.1'

Purge common, this will also uninstall libapache2-mod-php7.4

apt purge php7.4-common
apt purge php8.0-common
apt purge php8.1-common

Check again using dpkg.

How do you find  all PHP 8.2 packages?

dpkg -l | grep '^ii  php8.2'

How do I install PHP 8.4 on Ubuntu 20.04?

It’s not officially supported but you can do this:

sudo add-apt-repository ppa:ondrej/php
apt install php8.4-{cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,curl,xml,zip}

List of all options to turn on/off 2025

virtualmin modify-web --domain name | --all-domains
[--mode mod_php|cgi|fcgid|fpm | --default-mode]
[--php-children|--php-children-no-check number | --no-php-children]
[--php-version num]
[--php-timeout seconds | --no-php-timeout]
[--php-fpm-port | --php-fpm-socket]
[--php-fpm-mode dynamic|static|ondemand]
[--php-log filename | --no-php-log | --default-php-log]
[--php-mail | --no-php-mail]
[--cleanup-mod-php]
[--proxy http://... | --no-proxy]
[--framefwd http://... | --no-framefwd]
[--frametitle "title" ]
[--matchall | --no-matchall]
[--includes extension | --no-includes]
[--default-website]
[--access-log log-path]
[--error-log log-path]
[--document-dir subdirectory |
--move-document-dir subdirectory |
--subprefix subdirectory |
--move-subprefix subdirectory |
--fix-document-dir]
[--port number] [--ssl-port number]
[--url-port number] [--ssl-url-port number]
[--fix-options]
[--letsencrypt-renew | --no-letsencrypt-renew]
[--break-ssl-cert | --link-ssl-cert]
[--enable-fcgiwrap | --enable-suexec |
--disable-cgi]
[--sync-tlsa]
[--add-directive "name value"]
[--remove-directive "name value"]
[--protocols "proto .." | --default-protocols]
[--ssl-cert file | --default-ssl-cert]
[--ssl-key file | --default-ssl-key]
[--ssl-ca file | --default-ssl-ca]
[--default-ssl-paths]
[--www-to-domain | --domain-to-www |
--subdomain-to-domain | --no-redirect]

Reference

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top