← 返回 PHP 教程

PHP Windows:VS17 x64 Thread Safe 怎么选

下载 Windows 版 PHP 时,核心是先确定服务器模式:Apache 模块通常选 Thread Safe;IIS/FastCGI、CLI、Composer 和本地开发通常选 Non Thread Safe。

直接答案

VS17 表示用 Visual Studio 2022 运行库构建;x64 表示 64 位;Thread SafeNon Thread Safe 取决于 PHP 被哪个 Web Server 模式加载。普通 Windows 64 位开发机、CLI、Composer、IIS/FastCGI 场景,优先下载 VS17 x64 Non Thread Safe

这些标签分别是什么意思?

VS17

PHP 二进制文件使用 Visual Studio 2022 C/C++ 运行库构建,需要对应的 Microsoft Visual C++ Redistributable。

x64

64 位 Windows 版本。现代 Windows 服务器和开发机基本都应选择 x64,而不是 x86。

Thread Safe

适合 PHP 作为多线程服务器模块运行,例如 Windows 上的 Apache mod_php。

Non Thread Safe

适合 FastCGI、IIS、命令行脚本、Composer、本地开发和大多数 PHP-CGI/PHP-FPM 类似部署。

选择表

场景推荐版本原因
Apache module/mod_php on WindowsThread SafePHP 被多线程 Web Server 直接加载。
IIS/FastCGI 或 PHP-CGINon Thread SafeFastCGI 进程隔离运行,不需要 TS 构建。
CLI、Composer、本地脚本Non Thread Safe命令行是独立进程,NTS 更常见也更轻。
64 位 Windowsx64匹配系统架构和扩展生态。

检查当前 PHP 构建

php -v
php -i | findstr /i "Thread Architecture Compiler"

输出中如果看到 NTS,表示 Non Thread Safe;如果没有 NTS 或显示 Thread Safety enabled,则是 Thread Safe。扩展文件也要匹配 PHP 主版本、编译器、架构和 TS/NTS,否则可能加载失败。

和环境搭建怎么衔接?

如果只是跟着教程做开发环境,建议先读 PHP 环境安装,Windows 手动下载时选择 VS17 x64 Non Thread Safe,再把解压目录加入 PATH