#!/bin/bash
######系統配合
#下載ISO檔
#https://ftp.ubuntu-tw.org/ubuntu-releases/26.04.1/ 安裝
######鄭亮星 jls@mail.jls.idv.tw , jls550225@gmail.com , jls@acfs.tw
##安裝 phpMyAdmin-5.2.3-all-languages
#wget https://files.phpmyadmin.net/phpMyAdmin/5.2.3/phpMyAdmin-5.2.3-all-languages.zip
. /root/setup.txt
unzip phpMyAdmin-5.2.3-all-languages.zip
mv phpMyAdmin-5.2.3-all-languages /usr/share/phpMyAdmin
cp -arf /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php
sync
find /usr/share/phpMyAdmin/config.inc.php -type f -exec perl -i -pe s/"\$cfg\['blowfish_secret'\] = '';"/"\$cfg\['blowfish_secret'\] = sodium_hex2bin('5502259f45714194371b48fe362072dc3b019da7861558cd4ad29e4d6fb13851');"/g {} \;
mysql -uroot -p$Mysqlpasswd < /usr/share/phpMyAdmin/sql/create_tables.sql
cat > /etc/apache2/conf-available/phpMyAdmin.conf << EOF
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
AddDefaultCharset UTF-8
# Apache 2.4
Require all granted
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
# Apache 2.4
Require all granted
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
EOF
mkdir /usr/share/phpMyAdmin/tmp
chmod 777 /usr/share/phpMyAdmin/tmp
chown -R www-data:www-data /usr/share/phpMyAdmin
a2enconf phpMyAdmin
systemctl restart named.service
systemctl restart apache2.service