Skip to content

PHP - Installed Versions (Sensor)

A Tanium sensor that shows which PHP versions are on a Windows or Linux endpoint. It also shows how each one was installed, and whether a process uses it now. The sensor has one script for Windows and one script for Linux. It has no parameters.

The sensor is read-only. It changes nothing on the endpoint.

Test status

The Linux script was tested through Tanium on RHEL 9 and Ubuntu 24.04 lab endpoints. All tested cases gave the correct result, including a PHP update that still needs a restart. The Windows script has not been tested through Tanium yet. See Test results.

How the sensor works

Windows

The sensor looks for PHP in four places:

  1. The usual PHP folders:

    • C:\PHP
    • C:\Program Files\PHP and C:\Program Files (x86)\PHP
    • The PHP folders of IIS Express, in Program Files\IIS Express\PHP
    • XAMPP (C:\xampp\php), WampServer (C:\wamp64\bin\php), and Laragon (C:\laragon\bin\php)
    • C:\tools\php* (the folder that Chocolatey uses)

    The sensor also looks one folder level down, for example C:\Program Files (x86)\PHP\v7.1.

  2. The folders on the system PATH.

  3. The PHP folders that IIS uses. The sensor reads them from the FastCGI settings in C:\Windows\System32\inetsrv\config\applicationHost.config.
  4. Running processes. A PHP program that runs from a different folder is also found.

For each PHP file, the sensor does these steps:

  1. It reads the version from the file properties.
  2. It looks in the installed programs list for an installer whose folder holds the file. A PHP folder that someone copied from a zip file has no installer.
  3. It looks at the running processes to see if a process uses the file. For the Apache module, it looks at the Apache processes (httpd.exe).

The sensor skips php-win.exe. It is the same PHP as php.exe, without a console window.

Linux

The sensor looks for PHP in two places:

  1. The usual install folders. These folders hold the PHP from distribution packages and from these sources:
    • Remi (/opt/remi)
    • Red Hat Software Collections (/opt/rh)
    • cPanel (/opt/cpanel)
    • Plesk (/opt/plesk)
    • LiteSpeed (/usr/local/lsws)
    • Builds in /usr/local
  2. Running processes. A PHP program that runs from a different folder is also found.

For each PHP file, the sensor does these steps:

  1. It follows symbolic links to the real file. Thus /usr/bin/php and /usr/bin/php8.3 give one row, not two.
  2. It reads the version from the program with -n -v. The -n option starts PHP with no php.ini, so no extension loads. For the Apache module, it reads the version from the package.
  3. It asks rpm or dpkg-query which package installed the file.
  4. It looks at the running processes to see if a process uses the file.

The sensor skips these files on purpose:

  • Helper scripts such as php-config and phpize. They are not PHP itself.
  • Shell scripts with a PHP name, such as a php81 wrapper. The sensor reports only real programs.

Both scripts stop themselves after 20 seconds.

Use cases

Scenario What to look for Why it matters
A scanner reports an old PHP version Version and Package The row shows the exact PHP file and how it was installed. On Linux, the distribution adds security fixes to the package without a change to the main PHP version. Compare the package version with the fixed version in the vendor advisory.
An old PHP folder stays after IIS no longer uses it (Windows) Package shows No package and Running shows No No program updates or removes this folder. It stays on the disk, and the scanner keeps reporting it, until someone removes it. See Remove PHP Install.
A package update did not fix the finding (Linux) Running shows Yes, restart needed The update replaced the file, but the old program still runs. Restart the service (for example php-fpm or httpd).
PHP that no package manager or installer updates Package shows No package A person built or copied this PHP. An update of the operating system does not change it. The owner of the app must update it.
PHP that nobody uses Running shows No on every row of the endpoint The PHP is installed but not in use now. It can be a candidate for removal. Confirm with the owner first, because a scheduled job can start PHP later.

To see if anyone visits a PHP website on IIS, use IIS - PHP Usage. This sensor does not read web server logs.

Before you start

  • Windows endpoints with Windows PowerShell 5.1.
  • Linux endpoints with rpm or dpkg-query (RHEL, Rocky, AlmaLinux, Debian, Ubuntu, and similar).
  • On Linux, the timeout command, which is part of coreutils. Without it, the sensor takes the version from the package only.
  • A Tanium account with permission to create sensors.

Create the sensor

Step 1: Open a new sensor

  1. Sign in to the Tanium Console.
  2. Open the main menu, then go to Administration > Content > Sensors.
  3. Click Create Sensor.

Step 2: Details section

Field Value
Name PHP - Installed Versions
Description Lists PHP on Windows and Linux endpoints. Windows: php.exe, php-cgi.exe, phpdbg.exe, and the Apache PHP module (phpapache2.dll) in the usual PHP folders (C:\PHP, Program Files\PHP, IIS Express, XAMPP, WampServer, Laragon, C:\tools), the system PATH, the PHP folders that IIS uses, and running processes. Linux: the php, php-cgi, php-fpm, phpdbg, and lsphp programs and the Apache PHP module (libphp*.so) in the usual install folders (distribution packages, Remi, Red Hat Software Collections, cPanel, Plesk, LiteSpeed, /usr/local) and in running processes. Columns: PHP Path, Type, Version, Package (installer or package name and version, or No package), Running (Yes, Yes restart needed on Linux, No, or Unknown on Windows). Returns None when no PHP is found. Mac, Solaris, and AIX return Not Applicable. Does not look inside containers. Read-only.
Content Set Your own custom content set

Step 3: Settings section

Field Value
Category Miscellaneous (or any category you use for custom sensors)
Result Type Text
Max Sensor Age 1 and set the unit dropdown to Hours
Max String Age Leave Enable unchecked
Max Strings Leave Enable unchecked
Ignore case in result values Checked
Hide this sensor from sensor lists and parse results Unchecked
Split into multiple columns Checked

Step 4: Column settings

  1. Set Delimiter to |.
  2. Add these 5 columns in this order.
Index Column Name Value Type Ignore case Hidden
0 PHP Path Text Checked Unchecked
1 Type Text Checked Unchecked
2 Version Text Checked Unchecked
3 Package Text Checked Unchecked
4 Running Text Checked Unchecked

Version is Text because it can hold Unknown.

Step 5: Parameters section

None. Leave this section empty.

Step 6: Scripts section

Platform Enable Query Type Script
Windows Checked PowerShell Windows script below
Linux Checked UnixShell Linux script below
Mac Checked UnixShell Stub below
Solaris Checked UnixShell Stub below
AIX Checked UnixShell Stub below

Set Timeout to 30 seconds, above the time limit of 20 seconds that is in each script.

# Tanium sensor: PHP - Installed Versions (Windows)
#
# Sensor settings
#   Script type : PowerShell
#   Parameters  : none
#   Result type : Text, split into columns, delimiter |
#   Columns     : PHP Path | Type | Version | Package | Running
#                 (all Text)
#
# Finds php.exe, php-cgi.exe, phpdbg.exe, and the Apache PHP module (php*apache2*.dll).
# It looks in the usual PHP folders (C:\PHP, Program Files\PHP, IIS Express, XAMPP,
# WampServer, Laragon, C:\tools), in the folders on the system PATH, in the PHP folders
# that IIS uses, and in running processes.
# For each file it returns the PHP version, the installer from the installed programs
# list, and whether a process uses the file now.
# Skips php-win.exe (the same PHP as php.exe, without a console window).
# Pure PowerShell. No Python or Incident Response tools required.
# Read-only: nothing on the endpoint is changed.

$sw       = [Diagnostics.Stopwatch]::StartNew()
$budgetMs = 20000   # keep below the sensor timeout (30 seconds)

$rows    = New-Object 'System.Collections.Generic.List[string]'
$partial = $false

# A | inside a value would split the row into the wrong columns.
function Clean([string]$text) {
    if ($text) { (($text -replace '[\r\n]+', ' ') -replace '\|', '/').Trim() } else { '' }
}

# The kind of PHP file, from its name. Empty means "not a PHP file to report".
function Get-PhpType([string]$path) {
    $name = [IO.Path]::GetFileName($path).ToLowerInvariant()
    if ($name -eq 'php.exe')               { return 'CLI' }
    if ($name -eq 'php-cgi.exe')           { return 'CGI' }
    if ($name -eq 'phpdbg.exe')            { return 'Debugger' }
    if ($name -like 'php*apache2*.dll')    { return 'Apache module' }
    return ''
}

try {
    # In a 32-bit PowerShell on 64-bit Windows, $env:ProgramFiles points to the x86 folder.
    $pf64 = if ($env:ProgramW6432) { $env:ProgramW6432 } else { $env:ProgramFiles }
    $pf86 = ${env:ProgramFiles(x86)}
    $sd   = $env:SystemDrive
    # Use Sysnative when running as a 32-bit process so System32 is not redirected to SysWOW64.
    $sysDir = if (Test-Path "$env:windir\Sysnative") { "$env:windir\Sysnative" } else { "$env:windir\System32" }

    # --- Find the PHP files ------------------------------------------------------
    $found = New-Object 'System.Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase)

    function Add-PhpFolder([string]$folder) {
        if (-not $folder -or -not (Test-Path -LiteralPath $folder -PathType Container)) { return }
        foreach ($f in @(Get-ChildItem -LiteralPath $folder -File -ErrorAction SilentlyContinue |
                         Where-Object { $_.Name -like 'php*' })) {
            if (Get-PhpType $f.FullName) { [void]$found.Add($f.FullName) }
        }
    }

    # 1. Usual PHP folders. A * matches one folder level, for example C:\PHP\8.3.
    $patterns = @(
        "$sd\PHP", "$sd\PHP\*",
        "$pf64\PHP", "$pf64\PHP\*",
        "$pf64\IIS Express\PHP\*",
        "$sd\xampp\php",
        "$sd\wamp64\bin\php\*", "$sd\wamp\bin\php\*",
        "$sd\laragon\bin\php\*",
        "$sd\tools\php*"
    )
    if ($pf86) { $patterns += @("$pf86\PHP", "$pf86\PHP\*", "$pf86\IIS Express\PHP\*") }
    foreach ($pattern in $patterns) {
        foreach ($dir in @(Get-Item -Path $pattern -ErrorAction SilentlyContinue | Where-Object { $_.PSIsContainer })) {
            Add-PhpFolder $dir.FullName
        }
    }

    # 2. Folders on the system PATH.
    $machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
    foreach ($entry in @($machinePath -split ';')) {
        $dir = [Environment]::ExpandEnvironmentVariables($entry.Trim().Trim('"'))
        if ($dir -and (Test-Path -LiteralPath (Join-Path $dir 'php.exe'))) { Add-PhpFolder $dir }
    }

    # 3. PHP folders that IIS uses (FastCGI applications).
    $appHost = Join-Path $sysDir 'inetsrv\config\applicationHost.config'
    if (Test-Path -LiteralPath $appHost) {
        try {
            [xml]$cfg = Get-Content -LiteralPath $appHost -Raw -ErrorAction Stop
            foreach ($app in @($cfg.configuration.'system.webServer'.fastCgi.application)) {
                if ($app -and $app.fullPath) {
                    Add-PhpFolder (Split-Path -Path ([Environment]::ExpandEnvironmentVariables([string]$app.fullPath)) -Parent)
                }
            }
        } catch { }
    }

    # 4. Running processes. This finds PHP in folders that are not in the lists above.
    $procPaths = New-Object 'System.Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase)
    $procsRead = $true
    $procs = $null
    try { $procs = Get-CimInstance -ClassName Win32_Process -ErrorAction Stop }
    catch {
        try { $procs = Get-WmiObject -Class Win32_Process -ErrorAction Stop } catch { $procsRead = $false }
    }
    foreach ($p in @($procs)) {
        if (-not $p -or -not $p.ExecutablePath) { continue }
        [void]$procPaths.Add($p.ExecutablePath)
        if (Get-PhpType $p.ExecutablePath) { Add-PhpFolder (Split-Path -Path $p.ExecutablePath -Parent) }
    }

    # --- Installed programs list (both registry views) -------------------------
    $installs = New-Object 'System.Collections.Generic.List[object]'
    $hklm = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64')
    foreach ($root in 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
                      'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall') {
        $rk = $hklm.OpenSubKey($root)
        if (-not $rk) { continue }
        foreach ($sub in $rk.GetSubKeyNames()) {
            $sk = $rk.OpenSubKey($sub)
            if (-not $sk) { continue }
            $loc  = ([string]$sk.GetValue('InstallLocation')).Trim().Trim('"').TrimEnd('\')
            $name = ([string]$sk.GetValue('DisplayName')).Trim()
            $ver  = ([string]$sk.GetValue('DisplayVersion')).Trim()
            $sk.Close()
            # A location such as C:\ or C:\Program Files would match every folder on the drive.
            if (-not $loc -or -not $name) { continue }
            if (($loc -split '\\').Count -lt 2) { continue }
            if (@($pf64, $pf86, $env:windir) -contains $loc) { continue }
            $label = if ($ver -and $name -notlike "*$ver*") { "$name $ver" } else { $name }
            $installs.Add([pscustomobject]@{ Location = $loc; Label = $label })
        }
        $rk.Close()
    }
    $hklm.Close()

    # The installer whose folder holds this file (the deepest match wins).
    function Get-Installer([string]$folder) {
        $best = $null
        foreach ($i in $installs) {
            if ($folder -ieq $i.Location -or $folder.StartsWith($i.Location + '\', [StringComparison]::OrdinalIgnoreCase)) {
                if (-not $best -or $i.Location.Length -gt $best.Location.Length) { $best = $i }
            }
        }
        if ($best) { return $best.Label }
        return 'No package'
    }

    # Is an Apache process using this PHP module now?
    function Get-ModuleState([string]$dll) {
        $state = 'No'
        foreach ($p in [Diagnostics.Process]::GetProcessesByName('httpd')) {
            try {
                foreach ($m in $p.Modules) { if ($m.FileName -ieq $dll) { return 'Yes' } }
            } catch { $state = 'Unknown' }   # a 32-bit process cannot read a 64-bit process
        }
        return $state
    }

    # --- One row for each PHP file ------------------------------------------------
    foreach ($file in ($found | Sort-Object)) {
        if ($sw.ElapsedMilliseconds -gt $budgetMs) { $partial = $true; break }

        $type = Get-PhpType $file

        $ver = 'Unknown'
        try {
            $vi = (Get-Item -LiteralPath $file -ErrorAction Stop).VersionInfo
            foreach ($v in @($vi.ProductVersion, $vi.FileVersion)) {
                if ($v -match '\d+\.\d+\.\d+') { $ver = $Matches[0]; break }
            }
        } catch { }

        $pkg = Get-Installer (Split-Path -Path $file -Parent)

        if ($type -eq 'Apache module') { $run = Get-ModuleState $file }
        elseif (-not $procsRead)       { $run = 'Unknown' }
        elseif ($procPaths.Contains($file)) { $run = 'Yes' }
        else                           { $run = 'No' }

        $rows.Add(('{0}|{1}|{2}|{3}|{4}' -f (Clean $file), $type, (Clean $ver), (Clean $pkg), $run))
    }
} catch {
    # The reasons come from a fixed list, so the results can be filtered.
    Write-Output 'Error: Unexpected failure||||'
    exit 0
}

# --- Output: never empty ------------------------------------------------------
#   None            no PHP found
#   Error: <reason> something failed
if ($rows.Count) { $rows | Sort-Object -Unique }
if ($partial) { Write-Output 'Error: Time limit reached, results incomplete||||' }
if ($rows.Count -eq 0 -and -not $partial) { Write-Output 'None||||' }
#!/bin/sh
# Tanium sensor: PHP - Installed Versions (Linux)
#
# Sensor settings
#   Script type : UnixShell
#   Parameters  : none
#   Result type : Text, split into columns, delimiter |
#   Columns     : PHP Path | Type | Version | Package | Running
#                 (all Text)
#
# Finds the PHP programs (php, php-cgi, php-fpm, phpdbg, lsphp) and the Apache
# PHP module (libphp*.so) in the usual install folders and in running processes.
# For each one it returns the PHP version, the package that installed it, and
# whether a process uses it now.
# Skips helper scripts such as php-config and phpize. Does not look inside
# containers.
# POSIX sh. No Python or Incident Response tools required.
# Read-only: nothing is written.

TIME_LIMIT=20   # seconds; keep below the sensor timeout
start=$(date -u +%s)

PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export LC_ALL=C

NL='
'

# A | inside a value would split the row into the wrong columns.
clean() { printf '%s' "$1" | tr '|\t\r\n' '/   '; }

over_time() { [ $(($(date -u +%s) - start)) -ge "$TIME_LIMIT" ]; }

# A real program or library starts with the 4 bytes 0x7F E L F.
# This skips shell wrapper scripts with PHP names.
is_elf() { [ "$(dd if="$1" bs=1 skip=1 count=3 2>/dev/null)" = "ELF" ]; }

# The kind of PHP file, from its name. Empty means "not a PHP program".
php_type() {
    case "${1##*/}" in
        libphp*.so)          echo "Apache module" ;;
        php-fpm*|php*-fpm)   echo "FPM" ;;
        php-cgi*|php*-cgi)   echo "CGI" ;;
        phpdbg*)             echo "Debugger" ;;
        lsphp*)              echo "LiteSpeed" ;;
        php|php[0-9]*)       echo "CLI" ;;
        *)                   echo "" ;;
    esac
}

# --- Find the PHP files -------------------------------------------------------
# Each file is kept once, by its real path (symbolic links resolved).
found=''
add() {
    real=$(readlink -f "$1" 2>/dev/null) || return 0
    [ -f "$real" ] || return 0
    [ -n "$(php_type "$real")" ] || return 0
    is_elf "$real" || return 0
    case "$NL$found" in *"$NL$real$NL"*) return 0 ;; esac
    found="$found$real$NL"
}

# 1. Usual install folders: distribution packages, Remi, Red Hat Software
#    Collections, cPanel, Plesk, LiteSpeed, and builds in /usr/local.
for f in /usr/bin/php* /usr/sbin/php* /usr/local/bin/php* /usr/local/sbin/php* \
         /usr/local/php*/bin/php* /usr/local/php*/sbin/php* \
         /opt/remi/php*/root/usr/bin/php* /opt/remi/php*/root/usr/sbin/php* \
         /opt/rh/*php*/root/usr/bin/php* /opt/rh/*php*/root/usr/sbin/php* \
         /opt/cpanel/ea-php*/root/usr/bin/php* /opt/cpanel/ea-php*/root/usr/sbin/php* \
         /opt/plesk/php/*/bin/php* /opt/plesk/php/*/sbin/php* \
         /usr/local/lsws/lsphp*/bin/lsphp \
         /usr/lib64/httpd/modules/libphp*.so /usr/lib/httpd/modules/libphp*.so \
         /usr/lib/apache2/modules/libphp*.so /usr/local/apache2/modules/libphp*.so \
         /opt/remi/php*/root/usr/lib64/httpd/modules/libphp*.so; do
    [ -e "$f" ] && add "$f"
done

# 2. Running processes. This finds PHP in folders that are not in the list above.
#    An upgraded program that still runs shows as "<path> (deleted)".
procs=''
for d in /proc/[0-9]*; do
    exe=$(readlink "$d/exe" 2>/dev/null) || continue   # kernel threads have no exe
    procs="$procs$exe$NL"
    case "${exe##*/}" in php*|lsphp*) add "${exe% (deleted)}" ;; esac
done

# Libraries that running processes use (for the Apache module).
maps=$(cat /proc/[0-9]*/maps 2>/dev/null | grep -F 'libphp' | awk '{print $6, $7}' | sort -u)

# --- Facts about each file ----------------------------------------------------
# Package that installed the file: "name version", or nothing.
pkg_info() {
    if command -v rpm >/dev/null 2>&1; then
        out=$(rpm -qf --qf '%{NAME} %{VERSION}-%{RELEASE}\n' "$1" 2>/dev/null) || out=''
        if [ -n "$out" ]; then printf '%s' "$out" | head -1; return; fi
    fi
    if command -v dpkg-query >/dev/null 2>&1; then
        name=$(dpkg-query -S "$1" 2>/dev/null | head -1 | sed 's/: .*//')
        if [ -n "$name" ]; then
            ver=$(dpkg-query -W -f='${Version}' "$name" 2>/dev/null)
            printf '%s %s' "${name%%:*}" "$ver"
        fi
    fi
}

# PHP version from the program itself. -n: no php.ini, so no extension loads.
# Needs the timeout command, so a program that does not answer cannot stop the sensor.
bin_version() {
    command -v timeout >/dev/null 2>&1 || return 0
    timeout 5 "$1" -n -v </dev/null 2>/dev/null | sed -n '1s/^PHP \([0-9][0-9.]*[0-9]\).*/\1/p'
}

# "Yes", "Yes, restart needed" (the file was replaced after the process started), or "No".
running_state() {
    if [ "$2" = "Apache module" ]; then
        if printf '%s\n' "$maps" | grep -qxF "$1 "; then echo "Yes"; return; fi
        if printf '%s\n' "$maps" | grep -qxF "$1 (deleted)"; then echo "Yes, restart needed"; return; fi
    else
        if printf '%s' "$procs" | grep -qxF "$1"; then echo "Yes"; return; fi
        if printf '%s' "$procs" | grep -qxF "$1 (deleted)"; then echo "Yes, restart needed"; return; fi
    fi
    echo "No"
}

rows=''
timed=0
oldifs=$IFS
IFS=$NL
for p in $found; do
    IFS=$oldifs
    if over_time; then timed=1; break; fi

    type=$(php_type "$p")
    pkg=$(pkg_info "$p")
    [ -n "$pkg" ] || pkg="No package"

    ver=''
    [ "$type" = "Apache module" ] || ver=$(bin_version "$p")
    if [ -z "$ver" ] && [ "$pkg" != "No package" ]; then
        # Package version without the epoch ("2:") and the distribution suffix.
        ver=$(printf '%s' "${pkg#* }" | sed -n 's/^[0-9]*://; s/^\([0-9][0-9.]*[0-9]\).*/\1/p')
    fi
    [ -n "$ver" ] || ver="Unknown"

    run=$(running_state "$p" "$type")

    rows="$rows$(clean "$p")|$(clean "$type")|$(clean "$ver")|$(clean "$pkg")|$(clean "$run")$NL"
done
IFS=$oldifs

# --- Output: never empty ------------------------------------------------------
#   None            no PHP found
#   Error: <reason> something failed
[ -n "$rows" ] && printf '%s' "$rows" | sort -u
[ "$timed" -eq 1 ] && echo "Error: Time limit reached, results incomplete||||"
[ -z "$rows" ] && [ "$timed" -eq 0 ] && echo "None||||"
exit 0
#!/bin/sh
echo "Not Applicable||||"

Step 7: Save

Click Save.

Ask the question

All Windows endpoints:

Get Computer Name and PHP - Installed Versions from all machines with Is Windows equals True

All Linux endpoints:

Get Computer Name and PHP - Installed Versions from all machines with Is Linux equals True

Each endpoint shows one row for each PHP file. Endpoints with no PHP show None.

Only the Linux endpoints where an update needs a restart:

Get Computer Name and PHP - Installed Versions from all machines with PHP - Installed Versions:Running contains "restart needed"

Only one PHP branch, for example 7.4:

Get Computer Name and PHP - Installed Versions from all machines with PHP - Installed Versions:Version contains "7.4"

Reading the results

Output columns

Column Type Contents
PHP Path Text The full path of the PHP file. On Linux, symbolic links are resolved to the real file.
Type Text CLI (command line), CGI, FPM (Linux only), Debugger (phpdbg), LiteSpeed (lsphp, Linux only), or Apache module.
Version Text The main PHP version, for example 8.3.6. Unknown when the sensor cannot read a version.
Package Text How the file was installed. On Windows: the name and version from the installed programs list, for example XAMPP 8.2.12. On Linux: the package name and its full version, for example php8.3-cli 8.3.6-0ubuntu0.24.04.14. No package when no installer or package manager knows the file.
Running Text Yes: a process uses the file now. Yes, restart needed (Linux only): a process uses an older copy of the file. No: no process uses it now. Unknown (Windows only): the sensor could not read the running processes.

Example rows from a RHEL 9 endpoint, through Tanium:

/srv/testapp/bin/php|CLI|8.0.30|No package|Yes
/usr/bin/php-cgi|CGI|8.0.30|php-cli 8.0.30-8.el9_8.1|No
/usr/bin/php|CLI|8.0.30|php-cli 8.0.30-8.el9_8.1|No
/usr/sbin/php-fpm|FPM|8.0.30|php-fpm 8.0.30-8.el9_8.1|Yes, restart needed

On RHEL, the php-cli package also installs php-cgi.

Example rows from an Ubuntu 24.04 endpoint with Apache, through Tanium:

/usr/bin/php8.3|CLI|8.3.6|php8.3-cli 8.3.6-0ubuntu0.24.04.13|No
/usr/lib/apache2/modules/libphp8.3.so|Apache module|8.3.6|libapache2-mod-php8.3 8.3.6-0ubuntu0.24.04.13|Yes

Status results

Result Meaning
None The sensor found no PHP on the endpoint.
Not Applicable The endpoint is Mac, Solaris, or AIX.
Error: Time limit reached, results incomplete The sensor stopped after 20 seconds. The rows above it are correct, but some PHP files can be missing.
Error: Unexpected failure The Windows script failed before it could return results.

Troubleshooting

What you see Likely cause What to do
TSE-Error: Sensor evaluation timed out The sensor Timeout is below 30 seconds. Edit the sensor and check Step 6.
TSE-Error: No Sensor Definition for this Platform A script tab was left empty. Edit the sensor and add the script or the stub to that tab (Step 6).
All values in one column The column split was not saved. Edit the sensor and check Step 4.
An update or removal is done, but the old result still shows Tanium uses the saved result until the Max Sensor Age passes. Ask again after 1 hour.
Running still shows Yes, restart needed after the update The service was not restarted. Restart the service through your normal change process. Then ask again after 1 hour.
Running shows Unknown on a Windows endpoint The sensor could not read the running processes, or the Apache processes. Ask Get Computer Name and Running Processes from all machines with Running Processes contains "php" to see if PHP runs on that endpoint.
An endpoint is missing from the results The endpoint is offline, or it has not answered yet. Compare with Get Computer Name from all machines with Is Windows equals True or Get Computer Name from all machines with Is Linux equals True.

Limits

  • Other folders. PHP that is not in a usual folder, not on the system PATH, not used by IIS, and not running now is not found. On Windows, this includes PHP on other drives (for example D:\php) and PHP that one user installed in their own profile.
  • Containers. The sensor does not look inside container images. A PHP process that runs in a container can show with a path from inside the container. This case was not tested.
  • Old copy in an unusual folder (Linux). If a PHP program in an unusual folder was replaced while it runs, the sensor cannot see it. The old file is gone, and the new file is not in a usual folder.
  • Version from the program. The Version column shows the main PHP version. A Linux distribution can add security fixes without a change to that number. Use the Package column to compare with the vendor advisory.

Test results

All tests ran through Tanium in a lab.

Case Expected Result
Linux endpoint with no PHP None Pass
RHEL 9, php-cli and php-fpm installed, not running php, php-cgi, and php-fpm rows with the RHEL packages, Running No Pass
RHEL 9, php-fpm started FPM row shows Yes Pass
RHEL 9, php-fpm file replaced while it runs FPM row shows Yes, restart needed Pass
RHEL 9, PHP copy running from an unusual folder Found, No package, Yes Pass
Ubuntu 24.04, Apache with the PHP module running Apache module row shows Yes Pass
Ubuntu 24.04, PHP from a third-party repository Package and version from that repository Pass
Filter question on Running Endpoints with restart needed only Pass
Filter question on Version Endpoints with that PHP branch only Pass
Windows endpoint with no PHP None Not tested
Windows, PHP folder in C:\Program Files (x86)\PHP\v7.1 used by IIS php.exe and php-cgi.exe rows, No package Not tested
Windows, php-cgi.exe running for an IIS site CGI row shows Yes Not tested
Windows, PHP folder on the system PATH only Found Not tested