#!/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}" imagick_version="3.8.1" Install() { # 检查是否已经安装 is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=imagick$') if [ "${is_install}" != "" ]; then error "PHP-${version} imagick already installed" fi # 安装依赖 if [ ${OS} == "rhel" ]; then dnf install ImageMagick ImageMagick-devel -y elif [ ${OS} == "debian" ] || [ ${OS} == "ubuntu" ]; then apt-get install imagemagick libmagickwand-dev -y else error "Unsupported operating system" fi cd ${php_path}/src/ext rm -rf imagick dl "${php_path}/src/ext" "/php_exts/imagick-${imagick_version}.zip" unzip imagick-${imagick_version}.zip rm -f imagick-${imagick_version}.zip mv imagick-${imagick_version} imagick cd imagick ${php_path}/bin/phpize ./configure --with-php-config=${php_path}/bin/php-config make if [ "$?" != "0" ]; then rm -rf ${php_path}/src/ext/imagick error "PHP-${version} imagick compilation failed" fi make install if [ "$?" != "0" ]; then rm -rf ${php_path}/src/ext/imagick error "PHP-${version} imagick installation failed" fi sed -i '/;panel/a\extension=imagick' ${php_path}/etc/php.ini # 重载PHP systemctl reload php-fpm-${version}.service echo -e $HR echo "PHP-${version} imagick installation successful" } Uninstall() { # 检查是否已经安装 is_install=$(cat ${php_path}/etc/php.ini | grep '^extension=imagick$') if [ "${is_install}" == "" ]; then error "PHP-${version} imagick not installed" fi sed -i '/extension=imagick/d' ${php_path}/etc/php.ini # 重载PHP systemctl reload php-fpm-${version}.service echo -e $HR echo "PHP-${version} imagick uninstall successful" } if [ "$action" == 'install' ]; then Install fi if [ "$action" == 'uninstall' ]; then Uninstall fi