31 lines
1.9 KiB
Bash
31 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Verificamos si ya está todo configurado
|
|
if test -f /etc/phpmyadmin/config.inc.php; then
|
|
echo "Parece que ya está todo configurado (se hace nada)."
|
|
exit
|
|
fi
|
|
|
|
# Definiendo una contraseña vacía para root
|
|
echo "Definiendo contraseña para root (contraseña en blanco)."
|
|
systemctl start mariadb
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update
|
|
apt-get -yq install phpmyadmin
|
|
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); FLUSH PRIVILEGES;"
|
|
|
|
# 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
|
|
|
|
# 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..."
|
|
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 "Finalizado :)."
|