Solution
Created 3 month back

How to install PHP 8.* (ZTS) + parallel in ubuntu

  1. Update and Install Dependencies
sudo apt-get update

sudo apt-get install build-essential pkg-config autoconf bison re2c libxml2-dev \
libssl-dev libsqlite3-dev libcurl4-openssl-dev libpng-dev libjpeg-dev \
libonig-dev libfreetype6-dev libzip-dev libtidy-dev libwebp-dev libltdl7 libltdl-dev

  1. If it necessary: Remove any existing PHP 7
sudo apt-get purge php7.*

  1. Set PHP version and download distribution
VERSION=8.0.18
wget -qO- https://www.php.net/distributions/php-${VERSION}.tar.gz | tar -xz
cd php-${VERSION}/ext
git clone --depth=1 https://github.com/krakjoe/parallel.git

  1. Build and install PHP (ZTS) with parallel
cd ..
./buildconf --force -shared 

./configure \
    --prefix=/etc/php8z \
    --with-config-file-path=/etc/php8z \
    --with-config-file-scan-dir=/etc/php8z/conf.d \
    --disable-cgi \
    --with-zlib \
    --with-zip \
    --with-openssl \
    --with-curl \
    --enable-mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --enable-pcntl \
    --enable-gd \
    --enable-exif \
    --with-jpeg \
    --with-freetype \
    --with-webp \
    --enable-bcmath \
    --enable-mbstring \
    --enable-calendar \
    --with-tidy \
    --enable-zts \
    --enable-parallel

sudo make -j$(nproc)
sudo make install

sudo cp php.ini-development /etc/php8z/php.ini
sudo ln -s /etc/php8z/bin/php /usr/bin/phpz

  1. Additional config: OPCache needs to be turned on, otherwise may run to memory corruption error in parallel extension.
sudo mkdir /etc/php8z/conf.d
sudo nano /etc/php8z/conf.d/additional.ini

Source:

memory_limit=-1

[opcache]
zend_extension=opcache
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=128

Did you like the post? Share it with your friends!

Feedback