Improve mysql_configure script.
This commit is contained in:
parent
fb21761379
commit
80c26eca05
@ -1,30 +1,33 @@
|
|||||||
#!/bin/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
|
# Definiendo una contraseña vacía para root
|
||||||
echo "Definiendo contraseña para root (contraseña en blanco)."
|
echo "Definiendo contraseña para root (contraseña en blanco)."
|
||||||
systemctl start mariadb
|
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;"
|
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
|
# Verificamos si ya está todo configurado
|
||||||
sed -i "s/ \/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/" /etc/phpmyadmin/config.inc.php
|
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
|
# Añadimos las reglas nginx para poder ver phpmyadmin en http://localhost/phpmyadmin
|
||||||
if grep -e "phpmyadmin" /etc/nginx/sites-available/default >/dev/null
|
if grep -e "phpmyadmin" /etc/nginx/sites-available/default >/dev/null
|
||||||
then
|
then
|
||||||
echo "Se detectó que nginx ya tiene una configuración para PHPmyadmin (se hace nada)"
|
echo "Se detectó que nginx ya tiene una configuración para PHPmyadmin (se hace nada)"
|
||||||
else
|
else
|
||||||
echo "Configurando Nginx..."
|
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
|
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
|
fi
|
||||||
|
|
||||||
|
echo "Recargado configuración de nginx"
|
||||||
|
nginx -t && systemctl reload nginx
|
||||||
|
|
||||||
echo "Finalizado :)."
|
echo "Finalizado :)."
|
||||||
|
Loading…
Reference in New Issue
Block a user