#!/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 channel=${1} version=${2} phpmyadmin_path="${setup_path}/server/phpmyadmin" random_dir="$(cat /dev/urandom | head -n 16 | sha256sum | head -c 10)" webserver=$(acepanel setting get webserver) # 准备安装目录 rm -rf ${phpmyadmin_path} mkdir -p ${phpmyadmin_path} cd ${phpmyadmin_path} dl "${phpmyadmin_path}" "/phpmyadmin/phpMyAdmin-${version}-all-languages.zip" unzip -o phpMyAdmin-${version}-all-languages.zip mv phpMyAdmin-${version}-all-languages phpmyadmin_${random_dir} chown -R www:www ${phpmyadmin_path} chmod -R 755 ${phpmyadmin_path} rm -rf phpMyAdmin-${version}-all-languages.zip # 判断PHP版本 php_version="" if [ -d "${setup_path}/server/php/74" ]; then php_version="74" fi if [ -d "${setup_path}/server/php/80" ]; then php_version="80" fi if [ -d "${setup_path}/server/php/81" ]; then php_version="81" fi if [ -d "${setup_path}/server/php/82" ]; then php_version="82" fi if [ -d "${setup_path}/server/php/83" ]; then php_version="83" fi if [ -d "${setup_path}/server/php/84" ]; then php_version="84" fi if [ -d "${setup_path}/server/php/85" ]; then php_version="85" fi if [ "${php_version}" == "" ]; then rm -rf ${phpmyadmin_path} error "PHP not installed" fi # 写入 phpMyAdmin 配置文件 mkdir -p ${setup_path}/sites/phpmyadmin/config mkdir -p ${setup_path}/sites/phpmyadmin/log if [ "${webserver}" == "nginx" ]; then cat >${setup_path}/sites/phpmyadmin/config/nginx.conf <${setup_path}/sites/phpmyadmin/config/apache.conf < DocumentRoot ${setup_path}/server/phpmyadmin ErrorLog ${setup_path}/sites/phpmyadmin/log/phpmyadmin.log CustomLog ${setup_path}/sites/phpmyadmin/log/phpmyadmin.log combined Options Indexes FollowSymLinks AllowOverride All Require all granted SetHandler "proxy:unix:/tmp/php-cgi-${php_version}.sock|fcgi://localhost/" EOF fi # 设置文件权限 chown -R root:root ${setup_path}/sites/phpmyadmin/config/nginx.conf chmod -R 644 ${setup_path}/sites/phpmyadmin/config/nginx.conf chmod -R 755 ${phpmyadmin_path} chown -R www:www ${phpmyadmin_path} # 放行端口 firewall-cmd --permanent --zone=public --add-port=888/tcp firewall-cmd --reload acepanel app write phpmyadmin ${channel} ${version} if [ "${webserver}" == "nginx" ]; then systemctl reload nginx elif [ "${webserver}" == "apache" ]; then systemctl reload apache fi echo -e $HR echo "Installation successful" echo -e $HR