Installing PHP 7.2.11 in CentOS 7.4 with pthreads enabled
This steps are meant for PHP CLI threading applications. So web related appications are not installed along with.
OS Version: CentOS Linux release 7.4.1708 (Core)
First we need to install PHP. Version used is php-7.2.11
1. Download php-7.2.11.tar.gz source from http://php.net/get/php-7.2.11.tar.gz/from/a/mirror
2. Extract to /usr/src
3. cd /usr/src/php-7.2.11
4. ./configure --with-config-file-path=/usr/local/lib --with-tsrm-pthreads --enable-pthreads=shared --enable-maintainer-zts --enable-sockets
5. make
6. make test
7. make install
8. To see the php version installed
php -v
Now we need to install Pthreads. Source is taken from Github.
1. Download from https://github.com/krakjoe/pthreads.git
2. Extract to /usr/src/php-7.2.11/ext
3. This step may not be required, but this is how it got worked for me and i didnt tried the other way. Rename the extracted file from pthreads-master to pthreads.
mv /usr/src/php-7.2.11/ext/pthreads-master /usr/src/php-7.2.11/ext/pthreads
4. cd /usr/src/php-7.2.11/ext/pthreads
5. phpize
6. ./configure
7. make
8. make test
9. make install
Now we require to Rebuild our PHP installation
1. cd /usr/src/php-7.2.11
2. make clean
3. rm -f configure && ./buildconf --force
4. ./configure --with-config-file-path=/usr/local/lib --with-tsrm-pthreads --enable-pthreads=shared --enable-maintainer-zts --enable-sockets
5. make
6. make test
7. make install
At end of make install note this path
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-zts-20170718/
Next is the important and final step, to edit the configuration file (php.ini)
1. Give command -> php --ini
Output ->
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
2. Copy
file from /usr/src/php-7.2.11 to /usr/local/lib and rename the file to php.ini
cp /usr/src/php-7.2.11/php.ini-development /usr/local/lib/php.ini
3. Give command -> php --ini
Output ->
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Now the Configuration file is loaded
4. Add this line to /usr/local/lib/php.ini below
extension=/usr/local/lib/php/extensions/no-debug-zts-20170718/pthreads.so
5. Shows the modules loaded
php -m
In the loaded modules you shoud be able to see the pthreads