78 lines
2.1 KiB
Bash
78 lines
2.1 KiB
Bash
#!/bin/bash
|
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
|
|
|
|
source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh)
|
|
if [ $? -ne 0 ]; then
|
|
echo "Download public.sh failed, please check the network or try again later."
|
|
exit 1
|
|
fi
|
|
|
|
action=${1}
|
|
version=${2}
|
|
php_path="${setup_path}/server/php/${version}"
|
|
xdebug_version="3.5.0"
|
|
|
|
if [ ${version} -le "74" ]; then
|
|
xdebug_version="3.1.6"
|
|
fi
|
|
|
|
Install() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^zend_extension=xdebug')
|
|
if [ "${is_install}" != "" ]; then
|
|
error "PHP-${version} xdebug already installed"
|
|
fi
|
|
|
|
cd ${php_path}/src/ext
|
|
rm -rf xdebug
|
|
rm -rf xdebug-${xdebug_version}.tgz
|
|
dl "${php_path}/src/ext" "/php_exts/xdebug-${xdebug_version}.tgz"
|
|
|
|
tar -xzf xdebug-${xdebug_version}.tgz
|
|
mv xdebug-${xdebug_version} xdebug
|
|
rm -f package.xml
|
|
rm -f xdebug-${xdebug_version}.tgz
|
|
cd xdebug
|
|
${php_path}/bin/phpize
|
|
./configure --with-php-config=${php_path}/bin/php-config
|
|
make
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/xdebug
|
|
error "PHP-${version} xdebug compilation failed"
|
|
fi
|
|
make install
|
|
if [ "$?" != "0" ]; then
|
|
rm -rf ${php_path}/src/ext/xdebug
|
|
error "PHP-${version} xdebug installation failed"
|
|
fi
|
|
|
|
sed -i '/;panel/a\zend_extension=xdebug' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} xdebug installation successful"
|
|
}
|
|
|
|
Uninstall() {
|
|
# 检查是否已经安装
|
|
is_install=$(cat ${php_path}/etc/php.ini | grep '^zend_extension=xdebug$')
|
|
if [ "${is_install}" == "" ]; then
|
|
error "PHP-${version} xdebug not installed"
|
|
fi
|
|
|
|
sed -i '/zend_extension=xdebug/d' ${php_path}/etc/php.ini
|
|
|
|
# 重载PHP
|
|
systemctl reload php-fpm-${version}.service
|
|
echo -e $HR
|
|
echo "PHP-${version} xdebug uninstall successful"
|
|
}
|
|
|
|
if [ "$action" == 'install' ]; then
|
|
Install
|
|
fi
|
|
if [ "$action" == 'uninstall' ]; then
|
|
Uninstall
|
|
fi
|