Skip to content

Instantly share code, notes, and snippets.

@0xfff
Forked from erkanarslan/ubuntu-php5.6-zts-pthreads
Last active August 4, 2020 12:19
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save 0xfff/c6d832c3aba8770873fc5fae4af082a8 to your computer and use it in GitHub Desktop.
Save 0xfff/c6d832c3aba8770873fc5fae4af082a8 to your computer and use it in GitHub Desktop.
Installing php-zts on ubuntu 16.04
#####################################################################################
# INSTALL isolated PHP 7.2 ZTS (Thread-safe) with pthreads on Ubuntu 14.04 &16.04 ###
#####################################################################################
0) Possible dependencies
sudo apt-get install libxml2-dev
1) Install necessary bison version
wget http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb
wget http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb
sudo dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb
sudo dpkg -i bison_2.7.1.dfsg-1_amd64.deb
2) Download PHP
cd /usr/src
sudo git clone https://github.com/php/php-src
cd php-src
2.a) Optionally check out speicific branch
git checkout PHP-5.6
3) Download pthreads
cd ext
sudo git clone https://github.com/krakjoe/pthreads
cd ../
4) Compile
sudo ./buildconf --force
sudo ./configure --prefix=/opt/php-zts --with-config-file-path=/opt/php-zts/etc --enable-maintainer-zts --with-mysql --with-mysqli --enable-pthreads --enable-mbstring
optional: --with-apxs2=/usr/bin/apxs --enable-debug
sudo make -j8
sudo make test
sudo make install
sudo echo "extension=pthreads.so" > /opt/php-zts/modules.d/pthreads.ini
(i had to create the dir and file)
5) Symlinking
sudo ln -s /opt/php-zts/bin/php /usr/local/bin/php-zts
sudo ln -s /opt/php-zts/bin/phpize /usr/local/bin/phpize-zts
sudo ln -s /opt/php-zts/bin/php-config /usr/local/bin/php-config-zts
sudo ln -s /opt/php-zts/bin/php-cgi /usr/local/bin/php-cgi-zts
sudo ln -s /opt/php-zts/bin/phpdbg /usr/local/bin/phpdbg-zts
6)
sudo cp /usr/local/src/php-7.0.12/php.ini-production /usr/local/lib/php.ini
php-zts --version
>>php-zts --version
PHP 7.2.0-dev (cli) (built: Nov 3 2016 17:10:19) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
###################
# BUILD MODULES ###
###################
cd /usr/src
sudo git clone https://github.com/krakjoe/apcu
cd apcu
sudo phpize-zts
sudo ./configure --with-php-config=php-config-zts
sudo make -j8
sudo make test
sudo make install
sudo echo "extension=apcu.so" > /opt/php-zts/modules.d/apcu.ini
-- http://stackoverflow.com/questions/18033191/how-to-install-pthread-in-ubuntu-12-10
@C0rn3j
Copy link

C0rn3j commented Mar 3, 2018

Thanks a lot for this.

Here are some modifications I'd make:

replace make -j8 lines with the following (nproc gets number of cores/threads the machine has)

make -j$(nproc)

add 'mkdir /opt/php-zts/modules.d' before the command instead of the note.

sudo echo "extension=pthreads.so" > /opt/php-zts/modules.d/pthreads.ini
(i had to create the dir and file)

add the TLS flag to the configure in the compilation phase

--with-openssl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment