#!/bin/bash export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH : ' Copyright 2022 HaoZi Technology Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ' HR="+----------------------------------------------------" ARCH=$(uname -m) OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") downloadUrl="https://jihulab.com/haozi-team/download/-/raw/main/panel/phpmyadmin" setupPath="/www" phpmyadminPath="${setupPath}/server/phpmyadmin" phpmyadminVersion="5.2.1" randomDir="$(cat /dev/urandom | head -n 16 | md5sum | head -c 10)" # 准备安装目录 rm -rf ${phpmyadminPath} mkdir -p ${phpmyadminPath} cd ${phpmyadminPath} wget -T 60 -t 3 -O phpmyadmin.zip ${downloadUrl}/phpMyAdmin-${phpmyadminVersion}-all-languages.zip if [ "$?" != "0" ]; then echo -e $HR echo "错误:phpMyAdmin 下载失败" rm -rf ${phpmyadminPath} exit 1 fi unzip -o phpmyadmin.zip mv phpMyAdmin-${phpmyadminVersion}-all-languages phpmyadmin_${randomDir} chown -R www:www ${phpmyadminPath} chmod -R 755 ${phpmyadminPath} rm -rf phpmyadmin.zip # 判断PHP版本 phpVersion="" if [ -d "/www/server/php/74" ]; then phpVersion="74" fi if [ -d "/www/server/php/80" ]; then phpVersion="80" fi if [ -d "/www/server/php/81" ]; then phpVersion="81" fi if [ -d "/www/server/php/82" ]; then phpVersion="82" fi if [ "${phpVersion}" == "" ]; then echo -e $HR echo "错误:未安装 PHP" rm -rf ${phpmyadminPath} exit 1 fi # 写入 phpMyAdmin 配置文件 cat >/www/server/vhost/phpmyadmin.conf </dev/null 2>&1 firewall-cmd --reload elif [ "${OS}" == "debian" ]; then ufw allow 888/tcp >/dev/null 2>&1 ufw reload fi panel writePlugin phpmyadmin 5.2.1 systemctl reload openresty echo -e "${HR}\phpMyAdmin 安装完成\n${HR}"