Páginas

miércoles, 19 de octubre de 2011

Apache2 Mysql Php PhpMyadmin

Fuentes y créditos:
http://www.gentoo.org/proj/en/php/php-installing.xml
http://www.igorgarcia.es/blog/activar-relaciones-phpmyadmin
http://wiki.ballano.net/index.php/Error_Blowfish_phpmyadmin

Después de instalar Apache2, Mysql, Php y PhpMyAdmin en Gentoo he realizado los cambios siguientes para que todo funcione como un reloj:

Iniciando servicios:
carlos@hypatia ~ $ su
Password:
# /etc/init.d/apache2 start
 * Starting apache2 ...                                           [ ok ]
# /etc/init.d/mysql start
 * Starting  ...
 * Starting  (/etc/mysql/my.cnf)                             [ ok ]


Abrir con un editor httpd.conf y agregar ServerName localhost:

# vim /etc/apache2/httpd.conf
ServerName localhost

Configurar /var/www/localhost/htdocs/phpmyadmin/config.inc.php partiendo el archivo /var/www/localhost/htdocs/phpmyadmin/config.sample.inc.php:

cp /var/www/localhost/htdocs/phpmyadmin/config.sample.inc.php /var/www/localhost/htdocs/phpmyadmin/config.inc.php

Agregar -D php5 al archivo /etc/conf.d/apache2
# vi /etc/conf.d/apache2

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5"

PhpMyAdmin incluye opciones para relacionar tablas que deben ser activadas, por esto al clicar sobre el boton operaciones en la basedatos aparece el error, Las opciones adicionales para trabajar con tablas vinculadas fueron desactivadas. Para saber porqué, haga clic aqui, y veremos algo como esto:
localhost
$cfg['Servers'][$i]['pmadb'] ... OK
$cfg['Servers'][$i]['relation'] ... no recibió el OK [ Documentación ]
Opciones de relación general: Deshabilitado

$cfg['Servers'][$i]['table_info'] ... no recibió el OK [ Documentación ]
Mostrar las opciones: Deshabilitado

$cfg['Servers'][$i]['table_coords'] ... no recibió el OK [ Documentación ]
$cfg['Servers'][$i]['pdf_pages'] ... no recibió el OK [ Documentación ]
Creación de los PDF: Deshabilitado

$cfg['Servers'][$i]['column_info'] ... no recibió el OK [ Documentación ]
Mostrando los comentarios de la columna: Deshabilitado
Transformación del navegador: Deshabilitado

$cfg['Servers'][$i]['bookmarktable'] ... no recibió el OK [ Documentación ]
Consulta guardada en favoritos: Deshabilitado

$cfg['Servers'][$i]['history'] ... no recibió el OK [ Documentación ]
Historial-SQL: Deshabilitado

$cfg['Servers'][$i]['designer_coords'] ... no recibió el OK [ Documentación ]
Diseñador: Deshabilitado

$cfg['Servers'][$i]['tracking'] ... no recibió el OK [ Documentación ]
Seguimiento: Deshabilitado

$cfg['Servers'][$i]['userconfig'] ... no recibió el OK [ Documentación ]
Preferencias de usuario: Deshabilitado

1.- Desde la pestaña importar de phpmyadmin buscar (browser), el archivo
/var/www/localhost/htdocs/phpmyadmin/scripts/create_tables.sql clic en continuar para ejecutarlo:

La importación se ejecutó exitosamente, se ejecutaron 12 consultas. (create_tables.sql)
El mensaje anterior nos confirma el exito de la consulta.

2.- Editar el archivo config.inc.php y descomentar las siguientes líneas:

# vi /var/www/localhost/htdocs/phpmyadmin/config.inc.php

  /* Authentication type */
  $cfg['Servers'][$i]['auth_type'] = 'http';
  /* Server parameters */
  $cfg['Servers'][$i]['host'] = 'localhost';
  $cfg['Servers'][$i]['connect_type'] = 'tcp';
  $cfg['Servers'][$i]['compress'] = false;
  /* Select mysqli if your server has it */
  $cfg['Servers'][$i]['extension'] = 'mysql';
  $cfg['Servers'][$i]['AllowNoPassword'] = false;

  /*
   * phpMyAdmin configuration storage settings.
   */

  /* User used to manipulate with storage */
   $cfg['Servers'][$i]['controluser'] = 'pma';
   $cfg['Servers'][$i]['controlpass'] = 'pmapass';

  /* Storage database and tables */
   $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
   $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
   $cfg['Servers'][$i]['relation'] = 'pma_relation';
   $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
   $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
   $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
   $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
   $cfg['Servers'][$i]['history'] = 'pma_history';
   $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
   $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
   $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
  /* Contrib / Swekey authentication */

Cambiar en el mismo archivo cookies por http:
# vi /var/www/localhost/htdocs/phpmyadmin/config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'cookies':
$cfg['Servers'][$i]['auth_type'] = 'http':

Guardar y salir.

3.- Crear un usuario MySQL para utilizar la relación entre tablas (que será el que indicamos anteriormente como controluser con la contraseña indicada en controlpass) y asignarle los correspondientes permisos:
Desde la terminal:

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 112
Server version: 5.1.56-log Gentoo Linux mysql-5.1.56

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| phpmyadmin         |
| test               |
+--------------------+
4 rows in set (0.09 sec)

mysql> use phpmyadmin;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------------+
| Tables_in_phpmyadmin |
+----------------------+
| pma_bookmark         |
| pma_column_info      |
| pma_designer_coords  |
| pma_history          |
| pma_pdf_pages        |
| pma_relation         |
| pma_table_coords     |
| pma_table_info       |
| pma_tracking         |
| pma_userconfig       |
+----------------------+
10 rows in set (0.00 sec)

mysql> GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv) ON mysql.user TO 'pma'@'localhost';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT SELECT ON mysql.db TO 'pma'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT ON mysql.host TO 'pma'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

Reiniciar apache y acceder al PMA.

Salir de la terminal, y comprobar desde phpmyadmin los privilegios del usuario que acaba de crear (pma):



Si dejamos la autenticación mediante cookies y al cargar la páqina principal de phpmyadmin puede leerse:
El archivo de configuración ahora necesita salvoconducto (una frase secreta) (blowfish_secret). Debemos modificar el siguiente fichero
/var/www/localhost/htdocs/phpmyadmin/config.inc.php y añadir una clave en:

$cfg['blowfish_secret'] = 'palabra_clave'


Problemas:


El código fuente php se está mostrando!:
La razón más común es que short_open_tags está desactivado por defecto. Si el código hace uso de etiquetas cortas,

# vi /etc/php/apache2-php5.3/php.ini

short_open_tag = on

Reiniciar apache
# /etc/init.d/apache2 restart
 * Stopping apache2 ...                                   [ ok ]
 * Starting apache2 ...                                     [ ok ]



Linux es genial!.

No hay comentarios:

Publicar un comentario