Last active
December 12, 2021 08:57
-
-
Save bohanyang/63ad80f52f60c2194c44c598a93a2da2 to your computer and use it in GitHub Desktop.
The proper way to install a PHP extension
This file contains 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
#!/bin/bash | |
set -eu | |
ver=8.1 | |
api_ver=20210902 | |
sapi=cli | |
ext=$1 | |
ext_ver=$2 | |
prio=30 | |
[ $# -ge 3 ] && prio=$3 | |
curl -fsSL -D - -O "https://pecl.php.net/get/$ext-$ext_ver.tgz" | |
tar xf "$ext-$ext_ver.tgz" | |
cd "$ext-$ext_ver" | |
"phpize$ver" | |
./configure --with-php-config="php-config$ver" | |
make -j"$(nproc)" | |
sudo cp "modules/$ext.so" "/usr/lib/php/$api_ver" | |
sudo tee "/etc/php/$ver/mods-available/$ext.ini" << EOF | |
; priority=$prio | |
extension=$ext.so | |
EOF | |
echo -e "\nsudo phpenmod -v $ver -s $sapi $ext\n" |
Author
bohanyang
commented
Nov 18, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment