Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk9 min

How to Enable ZTS (Thread Safety) Support for PHP on Ubuntu

Build PHP with Zend Thread Safety on Ubuntu using an isolated source installation, verify the ZTS binary, and align pthreads, parallel, and server SAPIs with the same build.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You cannot switch an existing Ubuntu PHP binary from non-thread-safe (NTS) to Zend Thread Safety (ZTS). ZTS is selected when PHP is compiled. Build the required PHP version from source with --enable-zts, install it under a separate prefix such as /opt/php-zts, then build extensions and configure services against that same installation.

For PHP versions before 8.0 on non-Windows systems, the historical spelling was --enable-maintainer-zts. Current PHP releases use --enable-zts.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What ZTS changes in PHP

Zend Thread Safety changes the PHP engine so that its internal state can be used safely by multiple threads. It is required by extensions such as pthreads and parallel, which create or coordinate worker threads inside a PHP process. Those extensions also need compatible POSIX-thread development support.

PHP’s manual is explicit: “Zend Thread Safety cannot be enabled post build; it is a build time configuration option.” A package compiled as NTS cannot be converted by editing php.ini, loading a different extension, or installing a development package. The engine itself must be rebuilt.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

ZTS is not automatically the right choice for every web application. It can affect extension and SAPI compatibility, and a command-line ZTS binary does not turn an existing PHP-FPM pool, Apache module, or other server binary into a ZTS process. Plan each SAPI you intend to run and keep the first installation isolated while you validate it.

Distribution package or source build?

Ubuntu’s normal PHP packages are convenient to update, but whether a ZTS variant exists depends on the Ubuntu release and the packages enabled for that release. Do not assume that an NTS package can be reconfigured locally. Check the target release’s package set first; if it does not provide the exact ZTS build and extensions you need, use a source build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Consideration Ubuntu package Separate source build
ZTS availability Depends on the target Ubuntu release and available package variants; not established by the PHP source-build documentation. Explicitly selectable with --enable-zts.
PHP and extension versions Constrained by the distribution’s branches and packaged extension versions. You choose the released PHP source tree and must select extension versions that support it.
Isolation and rollback Integrated with Ubuntu’s package database and service paths. A prefix such as /opt/php-zts keeps the build beside the system PHP until you approve a switch.
Updates Security and maintenance updates follow Ubuntu packaging. You own rebuilds, security updates, configuration records, and deployment changes.
SAPI coverage Provided SAPIs are tied to the package build. Each CLI, FPM, Apache, or other SAPI must be built and configured to use the ZTS installation.
Reproducibility Package metadata records the build, but your configure choices are limited. You can record the source version, prefix, configure flags, and extension versions exactly.

If you need ZTS only to compile or run a command-line worker, an isolated source build may be sufficient. If a web service also needs ZTS, plan a separate FPM or Apache integration rather than assuming the CLI binary will be used by that service.

Prepare the Ubuntu build

Choose a PHP source release and installation prefix

Pick a released PHP source tree that matches the application and extensions you will run. Keep it separate from Ubuntu’s PHP, for example:

/opt/php-zts

The separate prefix lets you invoke the new binary by absolute path, compare behavior with the distribution binary, and remove or replace the custom installation without overwriting /usr/bin/php. Record the PHP version, Ubuntu release, compiler options, and intended SAPIs before you start.

Install compiler and development dependencies

PHP’s Ubuntu build instructions recommend preparing the build environment with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt build-dep php

This command obtains the dependencies declared for Ubuntu’s PHP source package. The exact package names vary by Ubuntu release. If the command cannot find a dependency, or configure later reports a missing header or library, install the corresponding *-dev package for that component and rerun the configuration step. Avoid copying a package list from an older Ubuntu tutorial: library names and supported PHP branches change.

Use a source release that already contains the generated configure script. If you are building from a development checkout instead, PHP documents that you must generate the script first:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
./buildconf

Run buildconf from the PHP source directory before running ./configure.

Build PHP with ZTS on Ubuntu

1. Enter the source directory

Change to the PHP source tree you selected. The following commands assume that the tree is the current directory and that you have already installed its dependencies.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Configure an isolated ZTS build

A minimal representative configuration is:

./configure --prefix=/opt/php-zts --enable-zts --with-tsrm-pthreads

--enable-zts enables thread safety in current PHP releases. --with-tsrm-pthreads selects the POSIX threads implementation for PHP’s thread-safe resource manager; it is the documented default backend.

The command above is deliberately small. Add only the options your application requires, such as database drivers, OpenSSL, XML support, a selected SAPI, or other extensions. The correct option names and available libraries depend on the PHP version and Ubuntu release. A larger copied command can silently introduce dependencies or produce a binary that does not match your application.

For non-Windows PHP versions before 8.0, use the historical option --enable-maintainer-zts instead of --enable-zts. Do not combine both spellings in one configuration. Confirm the option supported by the source version you selected.

3. Read every configuration error

If configure stops, treat its final error as a dependency diagnosis. It may identify a missing header, library, or development feature. Install the matching Ubuntu development package, then rerun the complete ./configure command. Keep the same prefix and ZTS flags while fixing dependencies so the resulting configuration remains intentional.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Compile and run the test suite

PHP’s documented source-build lifecycle is configure, make, make test, and make install:

make -j"$(nproc)"
make test
sudo make install

-j"$(nproc)" allows the build to use the available processor count. The test suite is a build check, not proof that your application, extensions, or production SAPI are compatible. Review failures, especially those involving the SAPIs and extensions you intend to deploy, before proceeding.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

5. Do not replace the system PHP yet

Installing under /opt/php-zts does not make it the default php command. That is useful during validation. Do not overwrite /usr/bin/php, change system alternatives, or stop an existing PHP service until the new binary and every required extension have been checked.

Verify that the binary is really ZTS

Run the binary from the prefix explicitly so your shell cannot select Ubuntu’s other PHP version. Inspect its configuration output for the thread-safety status:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/opt/php-zts/bin/php -i
/opt/php-zts/bin/php-config --configure-options
/opt/php-zts/bin/phpize --version

The first command displays the compiled PHP configuration, including whether thread safety is enabled. The second shows the configure options used for that installation. The third identifies the PHP development tool that will prepare extension builds.

Keep php, php-config, and phpize from the same prefix. PHP’s extension documentation warns that phpize and the development headers must match the PHP installation used to build an extension. Mixing /usr/bin/phpize with /opt/php-zts/bin/php, for example, can compile an extension for the wrong API or place it in the wrong directory.

During validation, use absolute paths:

/opt/php-zts/bin/php --version
/opt/php-zts/bin/php -m
/opt/php-zts/bin/php --ini

These commands identify the executable, loaded modules, and configuration files actually in use. Only after they show the expected prefix and module set should you consider adding the prefix’s bin directory to a user’s PATH.

Build pthreads or parallel against the ZTS installation

Requirements

pthreads and parallel require a PHP binary compiled with ZTS. They also require functioning POSIX-thread development support, including the relevant thread header. Installing either extension cannot retrofit ZTS into an NTS binary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use matching development tools

Build each extension with the phpize and php-config belonging to the ZTS prefix. A typical workflow is:

cd /path/to/extension-source
/opt/php-zts/bin/phpize
./configure --with-php-config=/opt/php-zts/bin/php-config
make -j"$(nproc)"
sudo make install

The exact configure options differ by extension release. Select an extension version that explicitly supports your PHP version; a ZTS engine alone does not make every extension release compatible.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

After installation, enable the module in the configuration used by the ZTS binary, then verify it with:

/opt/php-zts/bin/php -m
/opt/php-zts/bin/php --ri extension_name

Replace extension_name with the module’s actual name. If the module does not load, inspect the startup error for an API mismatch, missing shared library, wrong extension directory, or a module built with the wrong php-config.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why an NTS extension cannot simply be copied

PHP extensions are compiled against the engine and its build interfaces. An extension built for an NTS package may fail to load in ZTS, even when the PHP version number is identical. Rebuild or reinstall it with the ZTS development tools rather than copying a .so file from the distribution installation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Align CLI, FPM, Apache, and other SAPIs

A successful CLI build changes only the CLI executable you invoke. Existing PHP-FPM pools, Apache modules, queue workers, and service units continue to use their original binaries until they are separately built or reconfigured.

CLI applications

Call /opt/php-zts/bin/php directly from scripts, supervisors, and cron jobs while testing. If you later change PATH, document that change so operators know which PHP installation runs a job.

PHP-FPM

If the web application requires ZTS, the FPM SAPI must be part of the compatible ZTS build and its service configuration must point to that build’s FPM binary, configuration directory, socket, and extension directory. A ZTS CLI executable does not convert an already running NTS FPM service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache or another embedded SAPI

An Apache module or other embedded SAPI must likewise be built for the same PHP installation and thread model. Do not load a module compiled for the Ubuntu NTS package into the custom ZTS environment. Keep the old service available until the new SAPI starts cleanly and serves a controlled test.

Keep one coherent module set

Every SAPI that uses ZTS should resolve its configuration, php.ini, extension directory, php-config, and libraries from the same prefix and build. Mixed paths are a common cause of “works in CLI, fails in the web server” reports.

Troubleshoot common failures

“I enabled ZTS in php.ini, but PHP still reports NTS”

There is no runtime directive that enables ZTS. Rebuild PHP with the correct compile-time option and verify the new binary by absolute path. Confirm that your shell, service, and test script are not still invoking Ubuntu’s original PHP.

configure reports a missing header or library

Install the Ubuntu development package that provides the named header or library, then rerun the full configure command. Dependency package names differ across Ubuntu releases; use the error output and the target release’s package metadata rather than an old tutorial’s list.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The configure option is unknown

Check the PHP source version. Current releases use --enable-zts; pre-8.0 non-Windows releases used --enable-maintainer-zts. A development checkout may also need ./buildconf before options are recognized.

An extension fails with an API or thread-safety error

Rebuild the extension using the ZTS prefix’s phpize, matching php-config, and development headers. Confirm that the extension release supports the compiled PHP version and that the required POSIX-thread headers were available during its build.

The web server still runs the old PHP

Inspect the service’s executable path, environment, configuration directory, socket, and loaded modules. A CLI check cannot identify which FPM pool or Apache module the web server is using. Keep the old service intact until the new SAPI has been explicitly configured and tested.

The build passes tests but the application fails

make test checks PHP’s build; it does not validate every application, extension combination, or production SAPI. Compare the application’s required modules, configuration values, and extension versions with the ZTS installation, then test under the same SAPI and service account used in deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the installation reproducible and maintainable

Record the PHP source version, Ubuntu release, compiler and dependency packages, complete configure command, installation prefix, enabled extensions, extension versions, and SAPI settings. This record lets you rebuild after a security update or reproduce a working environment on another host.

  • Keep the source tree and build logs with your deployment records.
  • Use an explicit prefix instead of replacing distribution files.
  • Rebuild extensions whenever the PHP version or ZTS build changes.
  • Apply PHP and extension security updates deliberately; a source build does not inherit Ubuntu’s package update mechanism.
  • Test CLI, FPM, Apache, and worker processes separately if you deploy more than one SAPI.
  • Retain a rollback path to the known-good binary and service configuration.

When you are ready to make the ZTS build primary, change one execution path at a time, verify the active binary and modules, and keep the previous installation available until the application has completed its normal checks.

Decision checklist

  • Have you confirmed that the application or extension genuinely requires ZTS?
  • Does the selected PHP source release support the configure spelling you plan to use?
  • Did you install dependencies for the actual Ubuntu release?
  • Is the build installed under an isolated prefix?
  • Does php -i from that prefix show ZTS?
  • Do phpize, php-config, headers, and extensions come from the same prefix?
  • Have every required SAPI and service been aligned with the ZTS build?
  • Have you recorded the build flags and retained a rollback option?

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.