shell/install/php-spx

47 lines
1.4 KiB
Plaintext
Raw Normal View History

2022-12-11 06:48:30 +00:00
#!/bin/bash
##makedesc: Install php-spx
echo
echo "==============================================="
echo "Installing php-spx..."
echo "==============================================="
echo
installed() {
command -v "$1" >/dev/null 2>&1
}
! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1
! installed 'phpize' && echo 'ERROR: You need php-dev to be installed' && exit 2
! installed 'make' && sudo apt install -y make
! installed 'wget' && sudo apt install -y wget
2024-07-31 15:35:38 +00:00
[ -d "$HOME/install/php-spx" ] || mkdir -p "$HOME/install/php-spx"
2022-12-11 06:48:30 +00:00
wget https://github.com/NoiseByNorthwest/php-spx/archive/refs/heads/release/latest.zip -O /tmp/php-spx.zip \
2024-07-31 15:35:38 +00:00
&& unzip -oq /tmp/php-spx.zip -d "$HOME/install/php-spx" \
2022-12-11 06:48:30 +00:00
&& rm /tmp/php-spx.zip \
2024-07-31 15:35:38 +00:00
&& cd "$HOME/install/php-spx/php-spx-release-latest" \
2022-12-11 06:48:30 +00:00
&& phpize \
&& ./configure \
&& make \
&& sudo make install
PHPVER=`php -r 'echo ($v=explode(".",PHP_VERSION))[0].".".$v[1];'`
cat << EOF | sudo tee -a "/etc/php/${PHPVER}/mods-available/spx.ini"
; https://github.com/NoiseByNorthwest/php-spx/tree/release/latest#configuration
; https://habr.com/ru/post/505192/
; extension=spx.so
; spx.data_dir = '/tmp/spx'
spx.http_enabled = 0
spx.http_key = 'spx'
; spx.http_ip_whitelist = "127.0.0.1"
EOF
sudo ln -sf "/etc/php/${PHPVER}/mods-available/spx.ini" "/etc/php/${PHPVER}/cli/conf.d/99-spx.ini"
echo
echo "Finish!"
echo