Windows Server 2012 R2中PHP7.x版本报500.0内部服务器错误求助
Hey there, let's break down this issue you're facing. That error code 0xc0000135 is the critical clue here—it means the system can't locate a required dynamic link library (DLL) to run the PHP 7.x FastCGI process. Since PHP 5.3 works perfectly, the root cause is almost always missing or incompatible Visual C++ Redistributable packages (PHP 7.x relies on newer runtime libraries than the older PHP 5.3).
Here's a step-by-step solution to get your PHP 7.2/7.3/7.4 up and running smoothly:
1. Match PHP Version to the Correct VC++ Redistributable
PHP 7.2, 7.3, and 7.4 all require the Visual C++ Redistributable for Visual Studio 2019 (x86). Even though your server is 64-bit, since your PHP installation is 32-bit (notice the (x86) in the path), you must install the 32-bit version of the redistributable.
2. Clean Up Old VC++ Installs (Optional but Recommended)
Conflicting older VC++ versions can sometimes cause unexpected issues:
- Open Control Panel > Programs and Features
- Uninstall all entries labeled "Microsoft Visual C++ Redistributable" (all versions)
- Restart your server before moving to the next step
3. Install the Required VC++ Package
Download and install the x86 version of the Visual C++ 2019 Redistributable. Once installed, restart your server to ensure the libraries are properly registered system-wide.
4. Validate PHP's Ability to Run Independently
Before checking IIS, confirm PHP itself can execute without errors:
- Open Command Prompt as Administrator
- Run this command:
"C:\Program Files (x86)\PHP\v7.4\php-cgi.exe" -v - If this throws an error about a missing DLL (like
vcruntime140.dll), it confirms the VC++ redistributable wasn't installed correctly. Reinstall the package and try again.
5. Tweak IIS FastCGI and App Pool Settings
- Open IIS Manager, navigate to FastCGI Settings
- Locate the entry for
php-7.4.13and verify the executable path points correctly toC:\Program Files (x86)\PHP\v7.4\php-cgi.exe - Go to your website's application pool, set .NET CLR Version to No Managed Code (PHP doesn't rely on .NET runtime)
- Ensure the application pool identity (default is
IIS AppPool\DefaultAppPool) has Read & Execute permissions on theC:\Program Files (x86)\PHP\v7.4directory, and Read permissions onC:\inetpub\wwwroot
6. Verify php.ini Configuration
Open C:\Program Files (x86)\PHP\v7.4\php.ini and confirm these core settings are correct:
fastcgi.impersonate = 1 cgi.fix_pathinfo = 0 extension_dir = "ext"
You can also temporarily comment out non-critical extensions to rule out missing DLLs from extensions causing the crash.
Quick Note on Why PHP 5.3 Works
PHP 5.3 uses the older VC9 (Visual Studio 2008) redistributable, which is likely already pre-installed or was added to your Windows Server 2012 R2 system at some point. PHP 7.x moved to newer VC++ versions that aren't included by default.
内容的提问来源于stack exchange,提问作者Florim Salihu

