Compiling PHP7.4 with ZTS🔗

First, install necessary packages (as far as I am aware):

apt update
apt upgrade -y
apt-get install libzip-dev bison autoconf build-essential pkg-config git libltdl-dev libbz2-dev libxml2-dev libxslt1-dev libssl-dev libicu-dev libpspell-dev libenchant-dev libmcrypt-dev libpng-dev libjpeg62-turbo-dev libfreetype6-dev libmariadb-dev libreadline-dev libcurl4-openssl-dev sqlite3 libsqlite3-0 libsqlite3-dev libonig5 libonig-dev

Second, go to the location you want to compile in, in this case /opt. Also uncompress the archive and enter the new folder

cd /opt/
wget https://www.php.net/distributions/php-7.4.3.tar.gz        # Download PHP tar.gz
tar -zxvf php-7.4.3.tar.gz                    # Uncompress
rm -rf php-7.4.3.tar.gz                        # Remove archive
cd php-7.4.3/

Thid, we're going to compile the thing! Buildconf:

./buildconf --force

Prepare configuration of PHP compilation:

CONFIGURE_STRING="--prefix=/etc/php/7.4/ --with-bz2 --with-zlib --disable-cgi \
--enable-soap --enable-intl --with-openssl --with-readline --with-curl --enable-ftp \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets --with-pear \
--enable-pcntl --with-pspell --with-enchant --with-gettext --enable-exif --with-kerberos \
--with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg --with-imap --with-imap-ssl\
--with-xsl --enable-bcmath --with-zlib-dir --with-freetype --enable-gd --with-zip \
--enable-mbstring --enable-calendar --enable-simplexml --enable-json --with-mhash \
--enable-session --enable-xml --enable-opcache --enable-inline-optimization --with-xmlrpc \
--with-config-file-path=/etc/php7/cli --with-config-file-scan-dir=/etc/php7/etc \
--enable-cli --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data \
--enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-mbregex \
--enable-maintainer-zts"

Time for making:

./configure $CONFIGURE_STRING        # Start configuration, takes a while
make && make install

When it's done, you can test if all went according to plan - This should result in a "1":

/etc/php7/bin/php -r 'echo PHP_ZTS."\n";'

If for some reason PHP 7.3 got installed, remove that and purge. Remember to make symlinks from /etc/php/7.4/bin/ into /usr/bin/

Installing Parallel🔗

cd /opt/
git clone https://github.com/krakjoe/parallel.git
cd parallel/
/etc/php/7.4/bin/phpize
./configure --enable-parallel
make
make test
make install
cd /opt/php-7.4.3/
mkdir -p /etc/php/7.4/cli/
cp php.ini-production /etc/php/7.4/cli/php.ini
echo "extension=parallel.so" | sudo tee -a /etc/php/7.4/cli/php.ini
echo "zend_extension=opcache.so" | sudo tee -a /etc/php/7.4/cli/php.ini

Installing pecl/pear🔗

wget http://pear.php.net/go-pear.phar
/etc/php/7.4/bin/php go-pear.phar

Again remember to make symlinks