The Version Mismatch Between VC15 and vcruntime140.dll
When deploying PHP on Windows Server, specifically using builds linked against Visual Studio 2017 (vc15), a common stumbling block is ensuring the correct runtime environment is present. The error message 'vcruntime140.dll' 14.0 is not compatible with this PHP build linked with 14.16 indicates a specific version mismatch in the Visual C++ Redistributable packages on your system.
In the scenario described, you have installed vc_redist.x86.exe, which typically installs the latest available runtime components by default. However, PHP 7.4.1 NTS vc15 was compiled against a specific subset of these libraries. The error explicitly states that the DLL version 14.0 (which corresponds to the redistributable installed in older versions of Windows or older patch sets) is being detected, but your PHP binary expects version 14.16.
This discrepancy usually arises because modern Visual C++ Redistributables are cumulative. Installing a newer package often overwrites or replaces individual DLLs with newer versions. If your PHP build was compiled against an earlier iteration of the vcruntime (specifically the 14.0 release), and your server's registry points to that version, but the actual file on disk has been updated to 14.16 by a subsequent update, the loader fails when it detects this inconsistency during initialization.
Diagnosing the Environment
To resolve this without downgrading PHP, you must first verify exactly which runtime versions are present and how they are registered. You can check the installed redistributables by running:
Get-AppxPackage *Microsoft.VCLibs* | Select-Object Name, Version
Alternatively, inspecting the system directory for vcruntime140.dll will reveal its version string. If you run php -i after installation and see the warning persist, the issue is not with the PHP configuration itself but with the underlying OS libraries that PHP relies on for memory management and threading functions.
The Correct Resolution Strategy
The most direct fix is to ensure that the specific runtime version expected by the PHP binary is available. Since vc_redist.x86.exe installs a cumulative update, it might have replaced the older 14.0 DLL with 14.16 while your PHP build still references the older one in its internal checks or because the registry key for the "installed" version points to the old path.
A reliable approach is to uninstall the existing Visual C++ Redistributable and reinstall a specific version that matches the PHP build's requirements, though this is rare as most modern PHP builds are designed to work with the latest redistributables. A more practical solution often involves ensuring the correct architecture is matched. The error mentions x86, so ensure you have not inadvertently installed the x64 redistributable on a 32-bit PHP build, or vice versa, as mixing architectures can sometimes lead to confusion in version reporting, though less likely to cause this specific DLL mismatch.
If the system allows it, you can try installing the "Visual C++ Redistributable for Visual Studio 2015" which explicitly includes the older vcruntime140.dll versions that match the build environment of PHP 7.4.1 vc15. This ensures that the DLL version detected by the loader matches the version the PHP binary was compiled against.
Trade-offs and Best Practices
Downgrading the runtime to an older version is generally discouraged in production environments. The Visual C++ Redistributables are critical system components used by many other applications, not just PHP. Installing older versions can introduce security vulnerabilities if they lack patches for known exploits present in newer DLLs.
The ideal scenario is that your PHP build was compiled against the latest runtime (14.16) and you installed the matching redistributable. If you are forced to use an older PHP version, the trade-off is increased maintenance overhead. You must ensure compatibility between your web server software (like IIS or Apache), any other legacy applications running on the server, and the specific DLL versions required by each.
In a production setting, if this mismatch persists after aligning the runtime versions, the most robust engineering decision is to rebuild the PHP environment using a version of PHP that supports the latest Visual C++ Redistributable standards. This eliminates the need for maintaining legacy DLLs and ensures compatibility with future Windows updates. For many teams managing PHP infrastructure, utilizing containerized environments like Docker or leveraging managed hosting services abstracts away these specific runtime dependencies entirely, reducing the surface area for such conflicts.