34 lines
2.1 KiB
Bash
34 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Definiendo una contraseña vacía para root
|
|
echo "Definiendo contraseña para root (contraseña en blanco)."
|
|
systemctl start mariadb
|
|
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); FLUSH PRIVILEGES;"
|
|
|
|
# Verificamos si ya está todo configurado
|
|
if test -f /etc/phpmyadmin/config.inc.php; then
|
|
echo "Se ha detectado que phpmyadmin ya esta instalado"
|
|
else
|
|
echo "Instalando phpmyadmin..."
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update
|
|
apt-get -yq install phpmyadmin
|
|
|
|
# Permitimos el que se pueda loguear sin contraseña para usar el usuario root en phpmyadmin
|
|
sed -i "s/ \/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/" /etc/phpmyadmin/config.inc.php
|
|
fi
|
|
|
|
# Añadimos las reglas nginx para poder ver phpmyadmin en http://localhost/phpmyadmin
|
|
if grep -e "phpmyadmin" /etc/nginx/sites-available/default >/dev/null
|
|
then
|
|
echo "Se detectó que nginx ya tiene una configuración para PHPmyadmin (se hace nada)"
|
|
else
|
|
echo "Configurando Nginx para phpmyadmin..."
|
|
sed -i "s/server_name _;/server_name _;\n\nlocation \/phpmyadmin {\n root \/usr\/share\/;\n index index.php index.html index.htm;\n location ~ \^\/phpmyadmin\/\(.+\.php\)\$ {\n try_files \$uri =404;\n root \/usr\/share\/;\n fastcgi_pass unix:\/var\/run\/php\/php8.2-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$request_filename;\n include \/etc\/nginx\/fastcgi_params;\n fastcgi_param PATH_INFO \$fastcgi_script_name;\n fastcgi_buffer_size 128k;\n fastcgi_buffers 256 4k;\n fastcgi_busy_buffers_size 256k;\n fastcgi_temp_file_write_size 256k;\n fastcgi_intercept_errors on;\n }\n location ~* \^\/phpmyadmin\/\(.+\\.\(jpg\|jpeg\|gif\|css\|png\|js\|ico\|html\|xml\|txt\)\)\$ {\n root \/usr\/share\/;\n }\n}\nlocation \/phpMyAdmin {\n rewrite \^\/* \/phpmyadmin last;\n}/g" /etc/nginx/sites-available/default
|
|
fi
|
|
|
|
echo "Recargado configuración de nginx"
|
|
nginx -t && systemctl reload nginx
|
|
|
|
echo "Finalizado :)."
|