Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

php - how to install pthread in ubuntu 12.10

I have been strugling for hours on how to install pthread in my ubuntu server to allow php threading. Please help me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

HOW TO INSTALL IN LINUX SYSTEM'S:

The following instructions will result in an isolated installation of PHP that does not affect your current installation.

1) Checkout PHP sources into a new directory on your system

cd /usr/src
git clone https://github.com/php/php-src
cd php-src

1a) Optionally checkout a specific version of PHP

git checkout PHP-5.6

2) Download the pthreads sources to the build directory (/ext)

cd ext
git clone https://github.com/krakjoe/pthreads
cd ../

3) Configure new isolated PHP installation

./buildconf --force
./configure --prefix=/opt/php-zts 
            --bindir=/opt/php-zts/bin 
            --with-config-file-dir=/opt/php-zts 
            --with-config-file-scan-dir=/opt/php-zts/modules.d/ 
            --enable-pthreads=shared 
            --with-curl=shared,/usr 
            --with-zlib 
            --with-libxml2 
            --enable-simplexml 
            --with-mysql=mysqlnd 
            --with-pdo-mysql=mysqlnd 
            --enable-gd-native-ttf 
            --with-mysqli 
            --enable-shared 
            --enable-maintainer-zts 
            --enable-sockets 
            --with-curl=shared 
            --enable-mbstring
make -j8
make install
echo "extension=pthreads.so" > /opt/php-zts/modules.d/pthreads.ini

The configure command used here will result in a fairly standard installation with a sensible set of modules. If the build process fails, you should be able to resolve errors by installing developement packages, for example should the curl module fail to configure or build then

yum install curl-devel

Or the equivalent for your system should resolve the error, allowing the build to continue.

4) Symlink some useful things in /opt/php-zts/bin to /usr/local/bin

ln -s /opt/php-zts/bin/php /usr/local/bin/php-zts
ln -s /opt/php-zts/bin/phpize /usr/local/bin/phpize-zts
ln -s /opt/php-zts/bin/php-config /usr/local/bin/php-config-zts
ln -s /opt/php-zts/bin/php-cgi /usr/local/bin/php-cgi-zts
ln -s /opt/php-zts/bin/phpdbg /usr/local/bin/phpdbg-zts

At this point you have a working installation of PHP (version of your chosen branch or master if none) with pthreads available.

BUILDING MODULES FOR USE WITH ISOLATED INSTALLATION:

The procedure for building modules is as follows (APCu used for example):

cd /usr/src
git clone https://github.com/krakjoe/acpu
cd apcu
phpize-zts
./configure --with-php-config=php-config-zts
make -j8
make install
echo "extension=apcu.so" > /opt/php-zts/modules.d/apcu.ini

You must be sure to pass the correct php-config path when building modules since by default your system installation of PHP will be detected.

All blockquoted commands are ok for copypasta.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...