Reminder about PHP TS vs NTS

June 18, 2023 note-to-self

From PHP Documentation:

Thread Safety means that binary can work in a multithreaded webserver context, such as Apache 2 on Windows. Thread Safety works by creating a local storage copy in each thread, so that the data won’t collide with another thread.

So what do I choose? If you choose to run PHP as a CGI binary, then you won’t need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.So it really depends on the way that you want to use PHP:

  • Apache + LoadModule: Thread Safe
  • Apache + FastCGI: Non-Thread Safe
  • IIS: Thread Safe
  • IIS + FastCGI: Non-Thread Safe

Also from this stackoverflow question.