On Windows, PHP comes in two flavors: Thread Safe (TS) and Non-Thread Safe (NTS). The difference boils down to how the web server runs PHP and whether it needs the interpreter to handle multiple threads safely.
Key distinctions:
- Non-Thread Safe (NTS) → Designed for single-threaded or isolated request models. It’s the go-to when you run PHP via FastCGI (or CGI). This includes most modern IIS setups + FastCGI handler, and Apache + mod_fcgid / php-fpm style (though Apache on Windows usually goes the other way). NTS tends to be faster and more stable in non-multithreaded scenarios because it skips all the thread-safety overhead (locking, thread-local storage, etc.).
- Thread Safe (TS) → Built for multithreaded environments where PHP is loaded directly as a module into the web server process (e.g., Apache + mod_php on Windows, or older IIS ISAPI mode). TS enables Zend Thread Safety (ZTS), which copies certain data per thread so globals don’t stomp on each other. Historically people paired TS with IIS/ISAPI and Apache mod_php, but these days Microsoft themselves push NTS + FastCGI on IIS for better perf and stability.
Many third-party extensions (notably things like oci8 for Oracle, or others from PECL) ship separate builds:
- TS versions (filename often has “ts” or matches your PHP’s thread safety)
- NTS versions (“nts”)
If you grab the wrong one, you’ll get classic startup errors like “Module compiled with module API=xxxxxxx, debug=0, thread-safety=0, whereas this PHP was compiled with thread-safety=1” (or vice versa).
Quick check to see what you’ve got installed:
Open CMD and run:
php -i | findstr "Thread"
Look for:
Thread Safety => enabled→ You’re on TS (ZTS build)- No line, or
Thread Safety => disabled→ NTS
(Pro tip: php -i dumps everything; pipe to findstr just greps the relevant bit.)
Bottom line on Windows:
Download the extension that matches your PHP build’s thread safety flag. Mismatch = extension fails to load, usually with cryptic module API / thread-safety errors.
Modern recommendation (202x era)
Almost everyone on Windows should be using NTS + FastCGI (especially with IIS), so grab NTS PHP and NTS extensions unless you’re deliberately running old-school Apache mod_php (which is rare these days). TS still exists mostly for legacy module-mode compatibility.
Moral: Check php -i, match the build, save yourself hours of “why won’t this damn extension load” debugging.