How to recompile PHP 8.1.9/cPanel 104.0.7 with ZTS extension enabled?

Kadence

Active Member
Nov 25, 2006
32
1
158
I have cPanel & WHM 104 (build 7) on a CentOS 7.9 server, with PHP 8.1.9. I would like to install the PHP Parallel extension, which requires ZTS.

https://github.com/krakjoe/parallel
https://www.php.net/manual/en/parallel.setup.php
https://github.com/krakjoe/parallel/blob/develop/INSTALL.md

From the instructions there I tried installing with pecl:
/opt/cpanel/ea-php81/root/usr/bin/pecl install parallel
But at the end I get the error:
checking for ZTS... configure: error: parallel requires ZTS, please use PHP with ZTS enabled
ERROR: `/root/tmp/pear/parallel/configure --with-php-config=/opt/cpanel/ea-php81/root/usr/bin/php-config' failed
I also tried installing from source:
git clone https://github.com/krakjoe/parallel.git
cd parallel
/opt/cpanel/ea-php81/root/usr/bin/phpize
./configure --enable-parallel --with-php-config=/opt/cpanel/ea-php81/root/usr/bin/php-config
But I get the error:
checking for ZTS... configure: error: parallel requires ZTS, please use PHP with ZTS enabled
I asked my web host about this extension and they said:
On all of our servers that have control panels, PHP is RPM built and is not a source install so we cannot just compile new modules into it if they don't fit what the control panel has installed.

We are unable to compile in support for ZTS on this server since it is an RPM-provided install of apache and php.
Is there any way for me to manually add ZTS to my PHP? Do I need to re-compile, and if so would this carry risks? I don't really know what I'm doing and I don't want to break anything, and my web host is not wiling to do this for me.

I found this thread that describes how to re-make PHP:
https://stackoverflow.com/questions/59601583/how-to-install-php-zts-manually-on-the-centos-7

If I follow the instructions listed there with php-8.1.9.tar.gz, would there be any conflicts or issues with cPanel? Would cPanel later try to revert the changes or anything like that? Here's what I think the instructions from that thread look like, with 8.1.9 instead:
wget http://www.php.net/distributions/php-8.1.9.tar.gz && tar zxvf php-8.1.9.tar.gz
yum install -y libxml2-devel sqlite-devel
cd php-8.1.9 && ./buildconf --force && ./configure --enable-debug --enable-zts --prefix=/usr --with-config-file-path=/etc
make && make install
Would it be safe to execute these instructions? If I try this, is there anything I should back up first?

Any advice or suggestions or guidance is appreciated.
 

andrew.n

Well-Known Member
Jun 9, 2020
965
358
63
EU
cPanel Access Level
Root Administrator
You would need to build your own RPM for PHP to include ZTS. Similar to what @dalem said in this thread earlier:

 
  • Like
Reactions: Kadence and cPRex

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,289
2,434
363
cPanel Access Level
Root Administrator
You definitely don't want to try and manually compile anything on the cPanel server, as it won't work well and won't integrate with the cPanel tools at all. Creating that custom RPM using the details that @andrew.n provided is the best way to make this happen, even though it is a bit more complicated.
 
  • Like
Reactions: Kadence