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!.

viernes, 14 de octubre de 2011

Migrando a OpenRC

SysV init
SysV init scripts (/etc/init.d), usados para el control de inicio y apagado del sistema. El sistema de inicio System V controla el arranque de los programas en el instante de inicio de la máquina.
OpenRC es un sistema de arranque (rc system) con gestión de dependencias que trabaja con cualquier init proporcionado por el sistema, normalmente /sbin/init.

Originalmente el sistema rc de Gentoo formaba parte de baselayout 1 y estaba escrito completamente en bash. Esto conlleva varias limitaciones. Por ejemplo, ciertas llamadas al sistema necesitan ser accedidas durante el arranque, requiriendo agregar llamadas en C. Estas llamadas eran enlazadas estáticamente, aumentando notablemente el tamaño del sistema rc a lo largo del tiempo.

Migrando una máquina con procesador Intel core 2 duo x86_64 T5750 2.00GHz. Intel Mobile GM965/GL960 Integrated Graphics Controller.

Instalar cryptsetup
# emerge -av cryptsetup
Calculating dependencies... done!
[ebuild   R    ] dev-libs/libgcrypt-1.4.6  USE="static-libs*" 0 kB
[ebuild   R    ] dev-libs/popt-1.16-r1  USE="nls static-libs*" 0 kB
[ebuild   R    ] dev-libs/libgpg-error-1.10  USE="nls static-libs* -common-lisp" 0 kB
[ebuild  N     ] sys-fs/cryptsetup-1.1.3-r3  USE="nls -dynamic (-selinux)" 488 kB

Agrego al archivo /etc/make.conf las use "nls static-libs"
# vim /etc/make.conf
USE="... nls static-libs .."

# dispatch-conf
# revdep-rebuild
# emerge -v udev

# dispatch-conf

No es necesario recompilar hal, actualmente no se utiliza.

# emerge -v sysvinit
# dispatch-conf

# emerge -v openrc

 * Please read the migration guide available at:
 * http://www.gentoo.org/doc/en/openrc-migration.xml
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

 * IMPORTANT: 15 config files in '/etc' need updating.
 * See the CONFIGURATION FILES section of the emerge
 * man page to learn how to update config files.

Actualizo los 15 ficheros en /etc examinando uno por uno, son estos:

 /etc/conf.d/bootmisc          
 /etc/conf.d/consolefont       
 /etc/init.d/consolefont       
 /etc/conf.d/hostname          
 /etc/hosts                    
 /etc/conf.d/hwclock           
 /etc/conf.d/keymaps           
 /etc/init.d/keymaps           
 /etc/conf.d/modules           
 /etc/profile                  
 /etc/protocols                
 /etc/rc.conf                  
 /etc/sysctl.conf              
 /etc/conf.d/urandom
 /etc/timezone

Tiene que comprobar la migración desde /etc/modules.autoload.d/kernel-2.6 a /etc/conf.d/modules. El formato es diferente.

Llegado a este punto es "Muy Importante" comprobar los servicios que arrancarán en fase boot. Los principales están presentes: root, procfs, mtab, swap y fsck:

# ls -l /etc/runlevels/boot/
total 0
lrwxrwxrwx 1 root root 21 Oct 12 20:58 alsasound -> /etc/init.d/alsasound
lrwxrwxrwx 1 root root 20 Oct 12 20:58 bootmisc -> /etc/init.d/bootmisc
lrwxrwxrwx 1 root root 23 Oct 12 20:58 consolefont -> /etc/init.d/consolefont
lrwxrwxrwx 1 root root 25 Oct 12 20:58 device-mapper -> /etc/init.d/device-mapper
lrwxrwxrwx 1 root root 16 Oct 12 20:58 fsck -> /etc/init.d/fsck
lrwxrwxrwx 1 root root 20 Oct 12 20:58 hostname -> /etc/init.d/hostname
lrwxrwxrwx 1 root root 19 Oct 12 20:58 hwclock -> /etc/init.d/hwclock
lrwxrwxrwx 1 root root 19 Oct 12 20:58 keymaps -> /etc/init.d/keymaps
lrwxrwxrwx 1 root root 22 Oct 12 20:58 localmount -> /etc/init.d/localmount
lrwxrwxrwx 1 root root 19 Oct 12 20:58 modules -> /etc/init.d/modules
lrwxrwxrwx 1 root root 16 Oct 12 20:58 mtab -> /etc/init.d/mtab
lrwxrwxrwx 1 root root 18 Oct 12 20:58 net.lo -> /etc/init.d/net.lo
lrwxrwxrwx 1 root root 18 Oct 12 20:58 procfs -> /etc/init.d/procfs
lrwxrwxrwx 1 root root 16 Oct 12 20:58 root -> /etc/init.d/root
lrwxrwxrwx 1 root root 16 Oct 12 20:58 swap -> /etc/init.d/swap
lrwxrwxrwx 1 root root 18 Oct 12 20:58 sysctl -> /etc/init.d/sysctl
lrwxrwxrwx 1 root root 24 Oct 12 20:58 termencoding -> /etc/init.d/termencoding
lrwxrwxrwx 1 root root 19 Oct 12 20:58 urandom -> /etc/init.d/urandom

Aunque es automático durante la instalación de openrc compruebo que añade udev a sysinit correctamente:

# ls -l /etc/runlevels/sysinit
total 0
lrwxrwxrwx 1 root root 17 Oct 12 20:58 devfs -> /etc/init.d/devfs
lrwxrwxrwx 1 root root 17 Oct 12 20:58 dmesg -> /etc/init.d/dmesg
lrwxrwxrwx 1 root root 16 Oct 12 20:58 udev -> /etc/init.d/udev

Para registrar todo el arranque en /var/log/rc.log
# vim /etc/rc.conf
 rc_logger="YES"

Créditos y consultas
http://www.gentoo.org/doc/es/openrc-migration.xml
http://wiki.luispa.com

Linux es genial!.

lunes, 3 de octubre de 2011

Fichero make.conf Gentoo

 Fichero /etc/make.conf optimizado.

Maquina x86_64 Intel(R) Core(TM)2 Duo CPU T5750 @ 2.00GHz GenuineIntel GNU/Linux. Dell Inspiron 1525.

These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
#
USE_HARD="mmx sse sse2 sse3 ssse3"
CFLAGS="-march=core2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
#
#LDFLAGS="--as-needed"
#
ACCEPT_LICENSE="* @EULA"
#
# tres compilaciones paralelas
MAKEOPTS="-j3"
# colorear make.conf
NOCOLOR="no"
#
LINGUAS="en es"
#
# Portage
PORTDIR=/usr/portage            # ruta del arbol de portage
PKGDIR=${PORTDIR}/packages    # ruta del arbol de precompilados (GRP)
DISTDIR=${PORTDIR}/distfiles    # ruta de los fuentes
#
AUTOCLEAN="yes"
#
FEATURES="ccache"
 #
# crear fichero /usr/bin/ccache
CCACHE_SIZE="1G"
#
VIDEO_CARDS="intel vesa"
INPUT_DEVICES="udev keyboard mouse"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="-qt3 -qt4 -kde ${USE_HARD} static-libs nptl multilib ffmpeg hal dbus nls sqlite device-mapper X dvd alsa cdr gtk gnome"
#
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
#
GENTOO_MIRRORS="http://ftp.fi.muni.cz/pub/linux/gentoo/ \
ftp://ftp.fi.muni.cz/pub/linux/gentoo/ \
http://distfiles.gentoo.org \
http://www.ibiblio.org/pub/Linux/distributions/gentoo \
ftp://ftp.swin.edu.au/gentoo"
#
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"


Linux es genial!.