-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpmyadminAutoInstaller.sh
More file actions
61 lines (55 loc) · 2.12 KB
/
phpmyadminAutoInstaller.sh
File metadata and controls
61 lines (55 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#Update
apt-get install pwgen -y
apt update && apt upgrade -y
#HauptPakete lol
apt install ca-certificates apt-transport-https lsb-release gnupg curl nano unzip -y
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt update
apt install apache2 -y
apt install php7.4 php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-xsl php7.4-zip php7.4-bz2 libapache2-mod-php7.4 -y
apt install mariadb-server mariadb-client -y
#mysql_secure_installation
cd /usr/share
#wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -O phpmyadmin.zip
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip -O phpmyadmin.zip
unzip phpmyadmin.zip
rm phpmyadmin.zip
mv phpMyAdmin-*-all-languages phpmyadmin
chmod -R 0755 phpmyadmin
#Vhost Erstellen
echo -e '
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
</Directory>
<Directory /usr/share/phpmyadmin/templates>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Require all denied
</Directory>
' >> /etc/apache2/conf-available/phpmyadmin.conf
a2enconf phpmyadmin
systemctl reload apache2
mkdir /usr/share/phpmyadmin/tmp/
chown -R www-data:www-data /usr/share/phpmyadmin/tmp/
#MySQL Konfigurieren und User Erstellen
PASS=`pwgen -s 40 1`
mysql <<MYSQL_SCRIPT
CREATE USER 'pma'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON *.* TO 'pma'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
MYSQL_SCRIPT
ip=$(hostname -i)
#InstallationsLog / Zugangsdaten Erstellen
touch /root/phpmyadmin-data.txt
echo -e "######### PHPMYADMIN Zugang #########" >> /root/phpmyadmin-data.txt
echo -e "Link: http://"$ip"/phpmyadmin" >> /root/phpmyadmin-data.txt
echo -e "User: pma" >> /root/phpmyadmin-data.txt
echo -e "Passwort: $PASS" >> /root/phpmyadmin-data.txt