October 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 NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

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

ZTS is a compile-time PHP feature. This Ubuntu guide shows how to build it from source, verify the correct binary, compile compatible extensions, and avoid mixing CLI, FPM, Apache, and NTS components.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You cannot switch Zend Thread Safety (ZTS) on in an existing Ubuntu PHP binary. ZTS is selected when PHP is compiled, so the reliable Ubuntu method is to build the required PHP version from source with --enable-zts, install it in a separate prefix such as /opt/php-zts, and verify that binary before changing your services or system-wide php command. PHP’s manual states: “Zend Thread Safety cannot be enabled post build; it is a build time configuration option.”

What ZTS changes—and why a package reinstall is not enough

Zend Thread Safety makes PHP’s engine safe for threaded execution. Extensions such as pthreads and parallel require a PHP build with ZTS enabled and a working POSIX-threads development environment. An otherwise identical non-thread-safe (NTS) binary cannot be converted later by copying an extension, changing php.ini, or installing development headers.

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.

The setting belongs to PHP’s compilation configuration. The current configure option is --enable-zts. For non-Windows PHP releases before 8.0, the historical spelling was --enable-maintainer-zts; use the option appropriate for the source branch you selected rather than blindly applying an old tutorial.

Ubuntu’s distribution package may or may not provide a ZTS variant for the release and PHP branch you need. Availability, extension compatibility, and SAPI packaging must be checked for that exact Ubuntu release. A source build gives you explicit control over the flag and install location, but you become responsible for rebuilding and updating it.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Choose the build strategy before touching the system PHP

Decision point Ubuntu distribution package Separate source build
ZTS availability Depends on the target Ubuntu release and package branch; verify before relying on it. Explicitly selected with --enable-zts (or the pre-8.0 spelling where applicable).
PHP-version and extension compatibility Follows the versions and build options shipped for that release. You select the PHP source version and must select extension releases that support it.
Isolation and rollback Integrated system paths, so replacing or mixing binaries can affect existing applications. An explicit prefix such as /opt/php-zts can coexist with the distribution PHP until validation is complete.
Maintenance Ubuntu package updates handle the packaged build. You must track PHP security updates, repeat the configure flags, rebuild, test, and reinstall.
SAPI coverage Packaged CLI, FPM, or Apache components follow the package layout. A ZTS CLI build does not automatically change an existing FPM service or Apache module; each SAPI must use a matching build.
Reproducibility Controlled by the package metadata. You can record the source version, Ubuntu release, prefix, configure flags, and extension versions and repeat the build.

For an experiment or a single command-line worker, an isolated source prefix is the safest starting point. Do not overwrite /usr/bin/php while you are still determining whether the application and its extensions work with ZTS.

Prepare the Ubuntu host and source tree

1. Select a compatible PHP source version

Start with the PHP version your application and extensions support. The source version, extension versions, and SAPI choices need to agree; enabling ZTS does not remove normal PHP-version compatibility requirements. Keep the source tree and build artifacts separate from the Ubuntu-managed PHP installation.

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

Use a released PHP source tree when possible. If you are working from a development checkout, PHP documents that you must run ./buildconf first; that step generates the configure script used by the subsequent build.

2. Install compiler and development dependencies

From Ubuntu’s PHP build guidance, the broad preparation command is:

sudo apt build-dep php

This asks APT to install the build dependencies associated with Ubuntu’s PHP source package. Exact package names and available PHP branches vary by Ubuntu release. If APT cannot provide a dependency, or configure reports a missing header or library, install the corresponding *-dev package for that component and rerun the configuration step. Do not copy a package list from an older Ubuntu tutorial without checking the error against your release.

3. Confirm the source tree is ready

In a released tree, the supplied configure script should already exist. In a development checkout, run:

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

Run the command from the root of the PHP source tree. If it fails, resolve the reported build-tool or dependency problem before attempting to configure PHP; a missing generated script is not a ZTS problem.

Configure PHP with ZTS in an isolated prefix

From the source directory, a representative ZTS configuration is:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
./configure --prefix=/opt/php-zts --enable-zts --with-tsrm-pthreads

--enable-zts enables Zend Thread Safety. --with-tsrm-pthreads selects the POSIX-threads TSRM backend and is the documented default backend. The prefix keeps the result under /opt/php-zts instead of replacing Ubuntu’s existing PHP files.

This is a starting point, not a universal production command. Add only the extensions, database drivers, SSL, XML, and SAPI options your application actually requires. The exact flags and library requirements change with the PHP version and Ubuntu release. A successful ZTS configuration without the database or SAPI option your application needs is still an incomplete build.

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

Use the correct option for older source branches

For non-Windows PHP versions before 8.0, the historical option was:

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

Use the option documented by the source branch you selected. On current PHP releases, use --enable-zts; do not add both spellings simply to make an old command appear compatible.

Read configuration failures literally

When configure stops, its final error normally identifies the missing header, library, or feature. Install the matching development package, then rerun configure with the same prefix and ZTS flags. If the script rejects an option, check the PHP branch’s configure help and documentation rather than assuming the flag belongs to every release.

Compile, test, and install

PHP’s documented source-build lifecycle is configure, make, make test, and make install. After a successful configuration, build with the available CPU cores:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
make -j"$(nproc)"

Run the test suite before installation:

make test

The tests are a build check, not proof that your application, extensions, or web SAPI are production-ready. Review failures in the context of the PHP version and enabled options; this guide does not claim that any test suite was run on your machine.

Install into the prefix selected during configuration:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
sudo make install

With the representative prefix, the main executable and development helpers are expected under /opt/php-zts/bin, including php, php-config, and phpize. Keep the original Ubuntu PHP available until all consumers have been checked.

Verify that the binary you built is actually ZTS

Verification must use absolute paths first. This avoids accidentally inspecting Ubuntu’s NTS binary because another PHP version appears earlier in PATH.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Check the version and configuration summary:

    /opt/php-zts/bin/php -v
    /opt/php-zts/bin/php -i | grep -i "Thread Safety"

    The output should identify the intended PHP version and report the thread-safety setting for that binary. Treat the absolute path as authoritative while you validate the build.

  2. Inspect the configure options embedded in the installation:

    /opt/php-zts/bin/php-config --configure-options

    Confirm that the options include the ZTS selection appropriate for your source branch.

  3. Check the development helper used for extensions:

    /opt/php-zts/bin/phpize -v

    The helper, headers, and php-config must come from the same prefix. PHP’s extension documentation specifically warns that phpize and development headers must match the PHP installation against which an extension is built.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Only after those checks, test a temporary shell path:

    export PATH=/opt/php-zts/bin:$PATH
    php -v
    php-config --configure-options

    Use this session-level change to test scripts. Do not make it system-wide until you know which services should use the custom build.

    Rank #4
    Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
    • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
    • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
    • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
    • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
    • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

If the output does not show ZTS, stop and inspect the path and configure results. Installing into a new prefix does not guarantee that your shell, service unit, or extension command is using that prefix.

Build and install extensions against the ZTS PHP

pthreads and parallel are examples of extensions that require a ZTS PHP binary and working POSIX-thread development support. They cannot retrofit ZTS into an NTS executable. Select an extension release that explicitly supports the PHP version you compiled.

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.

Build such extensions with the matching development tools from the custom prefix. In practical terms, invoke the phpize and php-config located under /opt/php-zts/bin, not whichever versions happen to be first in the default path. A typical extension build uses that matching phpize, configures against that php-config, then runs its own make and installation step; follow the extension’s version-specific instructions for its exact flags.

  • Confirm the extension’s stated PHP-version support before compiling.
  • Confirm that the build sees the POSIX threads headers required by the extension.
  • Do not copy an extension binary built for an NTS PHP into the ZTS installation.
  • If an extension or SAPI was built for the old PHP installation, rebuild or reinstall it against the new php-config and phpize.

A ZTS build can reveal compatibility issues in extensions or SAPIs that worked with an NTS binary. Treat each extension as a separate compatibility decision, not as an automatic consequence of enabling one configure flag.

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

Keep CLI, FPM, and Apache components aligned

CLI is not the same as the web runtime

Installing /opt/php-zts/bin/php changes the command you invoke explicitly; it does not convert an existing PHP-FPM pool or Apache module. A web application can therefore continue running NTS PHP while your shell runs ZTS PHP, which makes extension tests and production behavior appear inconsistent.

Decide which SAPIs need the custom build

List every runtime that will load the thread-dependent extension: command-line workers, queue processes, FPM pools, Apache modules, or another SAPI. Build and configure the required SAPI components from a compatible PHP source tree, using the SAPI and library options required by your application. The exact configure flags vary by PHP version and Ubuntu libraries.

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

Before changing a service, verify its executable, configuration file, extension directory, and loaded modules. Keep the distribution runtime available as a rollback path. Do not point a service at a ZTS binary until its extensions and application have been tested with that same binary.

Prevent mixed helper and runtime paths

Common mixed-installation failures occur when php comes from /opt/php-zts/bin but phpize, php-config, headers, or an extension directory still comes from Ubuntu’s PHP. Always inspect the full path of each helper and use the matching prefix explicitly during extension builds.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Troubleshoot the failures that matter most

“ZTS” is absent after installation

  • Run the binary by absolute path; your shell may still be invoking Ubuntu’s NTS PHP.
  • Inspect php-config --configure-options from the same prefix.
  • Check that the configure command used the current option for the source branch, rather than an obsolete or rejected spelling.
  • If you changed options after a prior build, clean or use a fresh source tree and rebuild so stale configuration results are not mistaken for the new build.

Configure cannot find a header or library

Read the named component in the configure error, install its matching Ubuntu development package, and rerun configure. Dependency package names differ by Ubuntu release; the error output is more reliable than a copied package list.

An extension says ZTS is required

Verify the PHP executable and the extension build tools independently. The extension must be compiled for a ZTS PHP of a supported version, with the POSIX-thread development support it requires. Rebuild it using the custom prefix’s phpize, headers, and php-config; an NTS extension binary cannot add ZTS.

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.

The web application still behaves as NTS

Inspect the SAPI actually serving the request. A ZTS CLI executable does not alter FPM or Apache. Align the service’s PHP binary, extension directory, and configuration with the tested ZTS build, or leave that service on the distribution PHP if it does not need threaded extensions.

The build works but cannot be reproduced

Record the PHP source version, Ubuntu release, complete configure command, install prefix, enabled extensions, extension versions, and any dependency packages added after apt build-dep php. Reuse that record for upgrades and for rebuilding after a security release.

Operational checklist before making ZTS the default

  • The PHP source branch and every required extension explicitly support one another.
  • The build uses --enable-zts, or the documented pre-8.0 non-Windows spelling where appropriate.
  • --with-tsrm-pthreads is present when POSIX threads are the intended backend.
  • The binary, phpize, php-config, headers, and extension directory all come from the same prefix.
  • make test has been run and its results reviewed for this build.
  • CLI, FPM, Apache, and other required SAPIs have been identified and tested separately.
  • The original Ubuntu PHP remains available for rollback.
  • The exact build record is stored for future security and feature updates.

What the correct answer is for common Ubuntu questions

Can I enable ZTS in an existing PHP package?

Not after the binary has been built. You need a package that was itself compiled with ZTS, if one exists for your exact Ubuntu release and PHP branch, or a source build configured with the ZTS option.

Which flag should a current PHP build use?

Use --enable-zts on current PHP source. The non-Windows spelling --enable-maintainer-zts belongs to PHP versions before 8.0.

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

Will enabling ZTS automatically make parallel or pthreads work?

No. ZTS is necessary, but the extension must also support your PHP version, find the required POSIX-thread headers, and be compiled with matching ZTS development tools.

Is a separate prefix really necessary?

It is the safest validation approach. A prefix such as /opt/php-zts lets you compare and roll back without replacing the Ubuntu-managed /usr/bin/php before the new runtime is proven.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.