#!/bin/bash #Aktualizacja systemu sudo apt update && sudo apt upgrade -y #Instalacja Apache i MC sudo apt -y install apache2 mc #Instalacja PHP sudo apt -y install php php-{cli,mysql,json,opcache,xml,mbstring,gd,curl} #Instalacja serwera baz danych sudo apt -y install mariadb-server mariadb-client #Konfiguracja serwera baz danych (wykonanie m.in. "mysql_secure_installation") sudo mysql -e "UPDATE mysql.user SET Password = PASSWORD('Zaq12wsx') WHERE User = 'root'" sudo mysql -e "DELETE FROM mysql.user WHERE User='';" sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" sudo mysql -e "DROP DATABASE IF EXISTS test;" sudo mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';" sudo mysql -e "use mysql; update user set plugin='' where User='root';" sudo mysql -e "flush privileges;" #Instalacja phpmyadmin cd /tmp wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz sudo mkdir -p /www/phpmyadmin sudo tar xvf /tmp/Downloads/phpMyAdmin-latest-all-languages.tar.gz --strip-components=1 -C /www/phpmyadmin sudo cp /www/phpmyadmin/config.sample.inc.php /www/phpmyadmin/config.inc.php sudo chmod 660 /www/phpmyadmin/config.inc.php sudo chown -R www-data:www-data /www/phpmyadmin cat << 'EOF' > phpmyadmin.conf # phpMyAdmin default Apache configuration Alias /phpmyadmin /www/phpmyadmin Options SymLinksIfOwnerMatch DirectoryIndex index.php AddType application/x-httpd-php .php SetHandler application/x-httpd-php php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp php_admin_value open_basedir /www/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/www/php/php-gettext/:/www/php/php-php-gettext/:/www/javascript/:/www/php/tcpdf/:/www/doc/phpmyadmin/:/www/php/phpseclib/ php_admin_value mbstring.func_overload 0 AddType application/x-httpd-php .php SetHandler application/x-httpd-php php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp php_admin_value open_basedir /www/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/www/php/php-gettext/:/www/php/php-php-gettext/:/www/javascript/:/www/php/tcpdf/:/www/doc/phpmyadmin/:/www/php/phpseclib/ php_admin_value mbstring.func_overload 0 # Authorize for setup AuthType Basic AuthName "phpMyAdmin Setup" AuthUserFile /etc/phpmyadmin/htpasswd.setup Require valid-user # Disallow web access to directories that don't need it Require all denied Require all denied Require all denied EOF sudo mv phpmyadmin.conf /etc/apache2/conf-available/phpmyadmin.conf cp /etc/apache2/apache2.conf apache2.conf cat << 'EOF' >> apache2.conf Options Indexes FollowSymLinks AllowOverride None Require all granted EOF sudo mv apache2.conf /etc/apache2/apache2.conf sudo a2enconf phpmyadmin.conf sudo systemctl restart apache2