Last active
October 7, 2022 15:41
-
-
Save Chekote/bb51e4057f44e64b0905d60f77fd73c2 to your computer and use it in GitHub Desktop.
How to compile a PHP extension into a shared module for any PHP version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to compile a PHP extension into a shared module for any PHP version | |
# download and decompress required PHP version source (e.g. 5.6.30). See http://php.net/releases/ | |
wget http://php.net/get/php-5.6.30.tar.bz2/from/this/mirror -O php-5.6.30.tar.bz2 | |
tar xvf php-5.6.30.tar.bz2 | |
# compile and install PHP to temporary location (e.g. ~/php-install) | |
cd php-5.6.30/ | |
time ./configure --prefix=${HOME}/php-install | |
make -j 8 | |
make install | |
# check for phpize and add to PATH | |
cd ~/php-install/ | |
export PATH=./bin:$PATH | |
export PATH=$PWD/bin:$PATH | |
which phpize | |
phpize --version | |
# compile PHP extension from PHP source (e.g. bcmath) | |
cd ~/php-5.6.30/ext/bcmath | |
phpize | |
./configure | |
make -j4 | |
find . -name bcmath.so | |
# compile PHP extension from different repo (e.g. Redis). See https://github.com/phpredis/phpredis | |
cd | |
git clone https://github.com/phpredis/phpredis.git | |
cd ~/phpredis/ | |
phpize | |
./configure | |
make -j4 | |
find . -name redis.so | |
# move extension and configure PHP (e.g bcmath) | |
cp ~/php-5.6.30/ext/bcmath/modules/bcmath.so /usr/lib/php/20131226/ | |
echo "extension=bcmath.so" > /etc/php/5.6/mods-available/bcmath.ini | |
ln -s /etc/php/5.6/mods-available/bcmath.ini /etc/php/5.6/cgi/conf.d/25-bcmath.ini | |
php -i | grep bcmath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment