I want to build and use a custom PHP 5.5.30 on Ubuntu 14 including pthreads. But I also want to keep my regular PHP version on the side and switch back and forth between versions whenever I need to.
I lack time, I am not well-versed in building PHP - I have never done any build yet - and so I wanted a solution that would abstract the process in the simplest way possible.
To acheive that it seems using phpbrew is the correct way.
So I went and downloaded it, installed a handful of new packages that were apparently required for the build, and finally I launched the following:
phpbrew install --name php-5.5.30-zts 5.5.30 +bcmath +cli +ctype +dom +fileinfo +filter +json +mbregex +mbstring +mhash +pcre +pdo +posix +sockets +tokenizer +curl +zts +intl +mysql +pgsql +session
phpbrew use php-5.5.29-zts
The build terminates successfully and the newly built php is used by the CLI indeed...
Before:
me@ubuntu:/$ php -v
PHP 5.5.30-1+deb.sury.org~trusty+1 (cli) (built: Oct 4 2015 16:23:01)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
me@ubuntu:/$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
ldap
libxml
mbstring
mcrypt
memcached
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
After:
me@ubuntu:/$ php -v
PHP 5.5.30 (cli) (built: Oct 6 2015 11:48:18)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
me@ubuntu:/$ php -m
[PHP Modules]
bcmath
Core
ctype
date
dom
ereg
fileinfo
filter
hash
intl
json
libxml
mbstring
mhash
mysql
mysqli
mysqlnd
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
Reflection
session
SimpleXML
sockets
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
zlib
[Zend Modules]
BUT, as everyone can see... neither any zts module nor pthreads is listed in the available modules of the generated build.
So... Questions:
EDIT:
I also attempted the following builds to no avail. phpbrew refuses to include zts in its builds:
phpbrew install --name php-5.5.30-zts-only 5.5.30 -- --enable-maintainer-zts
phpbrew install --name php-5.5.30-zts-only 5.5.30 +zts -- --enable-maintainer-zts
phpbrew install --name php-5.5.30-zts-only 5.5.30 -- --enable-maintainer-zts --without-readline
All these are minimal PHP that I want to be built just with zts, for the sake of simplicity. None yields the zts module in the end when calling php -m
.
Maybe there is some sort of prerequisite? Some package to install maybe?
EDIT 2:
I tried the following:
phpbrew install 5.5.30 -- --enable-maintainer-zts
phpbrew use php-5.5.30
Command php -i | grep zts
yields the following result:
Configure Command => './configure' '--prefix=/home/linux1/.phpbrew/php/php-5.5.30' '--with-config-file-path=/home/linux1/.phpbrew/php/php-5.5.30/etc' '--with-config-file-scan-dir=/home/linux1/.phpbrew/php/php-5.5.30/var/db' '--with-pear=/home/linux1/.phpbrew/php/php-5.5.30/lib/php' '--disable-all' '--enable-session' '--enable-short-tags' '--with-zlib=/usr' '--with-libdir=lib/x86_64-linux-gnu' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr' '--enable-pcntl' '--with-pcre-regex' '--with-pcre-dir=/usr' '--enable-pdo' '--enable-phar' '--enable-posix' '--with-readline=/usr' '--enable-sockets' '--enable-tokenizer' '--enable-dom' '--enable-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--with-libxml-dir=/usr' '--enable-zip' '--with-openssl=yes' '--enable-maintainer-zts'
extension_dir => /home/linux1/.phpbrew/php/php-5.5.30/lib/php/extensions/no-debug-zts-20121212 => /home/linux1/.phpbrew/php/php-5.5.30/lib/php/extensions/no-debug-zts-20121212
Not sure if it helps.
Conclusion:
I forgot to install the pthreads extension, using the following:
phpbrew ext install pthreads 2.0.10
Note that you need to use (phpbrew use php-my-build
) the php version on which you want to install the extension for it to be installed.
Also, note that installing pthreads
will only work if +openssl
was included as a variant (if not, trying to call the package remote HTTPS URL will fail).
Yes, phpbrew is good idea to use for different php version on one pc without need to have several virtual machines.
Fot zts you should specify option like this -- --enable-maintainer-zts
Steps:
1. phpbrew install php-5.5.30 -- --enable-maintainer-zts
2. phpbrew use php-5.5.30
3. phpbrew ext install pthreads 2.0.10