This repository has been archived on 2024-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
thelinuxlist/scripts/unattended/pmainstall.sh

67 lines
4.5 KiB
Bash

#!/usr/bin/env bash
trap 'exit 130' INT
while [ "$go" != 'apache' ] && [ "$go" != 'nginx' ]; do
read -p "Would you like to install using Nginx or Apache? (nginx/apache) " go
done
if [ "$go" == 'nginx' ]; then
sudo apt update && apt upgrade -y
sudo apt-get install build-essential lsb-release software-properties-common -y
sudo add-apt-repository --yes ppa:ondrej/nginx && sudo add-apt-repository --yes ppa:ondrej/php && sudo apt install php-fpm software-properties-common phpmyadmin php-mbstring php-zip php-gd php-json php-curl nginx-full php-mysql -y
sudo systemctl stop nginx
sudo wget -O /etc/nginx/conf.d/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmanginx.conf
sudo systemctl enable nginx
sudo systemctl start nginx
## Updating phpMyAdmin.
PMA_VER="5.2.1"
sudo rm -rf /usr/share/phpmyadmin.bak
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
sudo mkdir /usr/share/phpmyadmin/
sudo wget https://files.phpmyadmin.net/phpMyAdmin/$PMA_VER/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz -P /usr/share/phpmyadmin/
sudo tar xzf /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz -C /usr/share/phpmyadmin/
sudo mv /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages/* /usr/share/phpmyadmin
sudo mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz
## Thanks https://stackoverflow.com/users/3266847/benjamin-w
randomBlowfishSecret=$(openssl rand -base64 22)
sudo sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
sudo systemctl restart nginx
sudo ufw allow 8080
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 )
intenalip=$(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://${intenalip}:8080"
echo "Or If you are using a VPS at http://${publicipaddress}:8080"
echo -e "=================================================================="
fi
if [ "$go" == 'apache' ]; then
sudo apt update && apt upgrade -y
sudo apt-get install build-essential lsb-release software-properties-common -y
sudo add-apt-repository --yes ppa:ondrej/apache2 && apt install apache2 libapache2-mod-php php-fpm software-properties-common phpmyadmin php-mbstring php-zip php-gd php-json php-curl php-mysql -y
sudo systemctl stop apache2
sudo wget -O /etc/apache2/sites-enabled/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmaapache.conf
sudo systemctl restart php-fpm
sudo systemctl reload apache2
sudo systemctl enable apache2
## Updating phpMyAdmin.
PMA_VER="5.2.1"
sudo rm -rf /usr/share/phpmyadmin.bak
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
sudo mkdir /usr/share/phpmyadmin/
sudo wget https://files.phpmyadmin.net/phpMyAdmin/$PMA_VER/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz -P /usr/share/phpmyadmin/
sudo tar xzf /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz -C /usr/share/phpmyadmin/
sudo mv /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages/* /usr/share/phpmyadmin
sudo mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages /usr/share/phpmyadmin/phpMyAdmin-"$PMA_VER"-all-languages.tar.gz
## Thanks https://stackoverflow.com/users/3266847/benjamin-w
randomBlowfishSecret=$(openssl rand -base64 22)
sudo sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
sudo systemctl restart apache2
sudo ufw allow 8080
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 )
intenalip=$(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://${intenalip}:8080"
echo "Or If you are using a VPS at http://${publicipaddress}:8080"
echo -e "=================================================================="
fi