78 lines
3.0 KiB
Bash
78 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
trap 'exit 130' INT
|
|
|
|
# Confirmation prompt
|
|
while true; do
|
|
read -r -p "Would you like to install phpMyAdmin? [Y/n] " input
|
|
|
|
case $input in
|
|
[yY][eE][sS]|[yY])
|
|
break
|
|
;;
|
|
[nN][oO]|[nN])
|
|
echo "phpMyAdmin installation aborted."
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "That wasn't an option..."
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Web server selection prompt
|
|
while [ "$go" != 'apache' ] && [ "$go" != 'nginx' ]; do
|
|
read -p "Would you like to install using Nginx or Apache? (nginx/apache) " go
|
|
done
|
|
|
|
# Update and upgrade system packages
|
|
apt update && apt upgrade -y
|
|
|
|
# Install dependencies and add repositories
|
|
apt-get install build-essential lsb-release software-properties-common -y
|
|
if [ "$go" == 'nginx' ]; then
|
|
add-apt-repository --yes ppa:ondrej/nginx
|
|
add-apt-repository --yes ppa:ondrej/php
|
|
apt install nginx-full phpmyadmin php-{mbstring,zip,fpm,gd,json,curl,mysql} unzip -y
|
|
systemctl stop nginx
|
|
wget -O /etc/nginx/conf.d/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmanginx.conf
|
|
systemctl enable nginx
|
|
systemctl start nginx
|
|
elif [ "$go" == 'apache' ]; then
|
|
add-apt-repository --yes ppa:ondrej/apache2
|
|
apt install apache2 libapache2-mod-php phpmyadmin php-{mbstring,zip,fpm,gd,json,curl,mysql} unzip -y
|
|
systemctl stop apache2
|
|
wget -O /etc/apache2/sites-enabled/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmaapache.conf
|
|
systemctl restart php-fpm
|
|
systemctl reload apache2
|
|
systemctl enable apache2
|
|
fi
|
|
|
|
# Update phpMyAdmin
|
|
rm -rf /usr/share/phpmyadmin.bak
|
|
mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
|
mkdir /usr/share/phpmyadmin/
|
|
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz -P /usr/share/phpmyadmin/
|
|
tar -xzf /usr/share/phpmyadmin/*.tar.gz -C /usr/share/phpmyadmin/
|
|
mv /usr/share/phpmyadmin/phpMyAdmin-*-all-languages/* /usr/share/phpmyadmin
|
|
mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
|
|
|
|
# Set random Blowfish secret
|
|
randomBlowfishSecret=$(openssl rand -base64 22)
|
|
sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
|
|
|
|
# Restart web server and allow connections
|
|
if [ "$go" == 'nginx' ]; then
|
|
systemctl restart nginx
|
|
elif [ "$go" == 'apache' ]; then
|
|
systemctl restart apache2
|
|
fi
|
|
ufw allow 8080
|
|
|
|
# Display information
|
|
echo -e "=================================================================="
|
|
publicipaddress=$(curl -sS --connect-timeout 10 -m 60 https://ipv4.icanhazip.com/ || curl -sS --connect-timeout 10 -m 60 https://api.ipify.org )
|
|
internalip=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
|
|
echo "phpMyAdmin should be available at http://${internalip}:8080"
|
|
echo "Or if you are using a VPS, at http://${publicipaddress}:8080"
|
|
echo -e "=================================================================="
|