?>/script>'; } ?> LAMP en Openwrt - Soluciones (httpd close_wait, arranque, PHP,MySQL,phpmyadmin) Widgets Magazine

Autor Tema: LAMP en Openwrt - Soluciones (httpd close_wait, arranque, PHP,MySQL,phpmyadmin)  (Leído 13331 veces)

0 Usuarios y 1 Visitante están viendo este tema.

CCCP

  • Visitante
Buenas:

Router: Hg556a
Firm: OpenWrt Barrier Breaker r42930 / LuCI Trunk (0.12+svn-r10530)
Estado: Tengo configurado Openwrt para acceso local y remoto con puertos cambiados: he tocado uhttpd.conf y el cortafuefos con traspaso (NAT) funcioanando para acceso web a luci y acceso ssh.

La siguiente cosa que he querido hacer es probar Apache y aquí me viene el problema.
No accedo al It Works de Apache.

Pasos y configuración:

He instalado Apache siguiendo la pautas del hilo: http://wiki.openwrt.org/doc/howto/http.apache
Código: [Seleccionar]
opkg update
opkg install apache

Código: [Seleccionar]
vi /etc/apache/httpd.conf

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
#ServerRoot "/usr"
ServerRoot "/usr/share/htdocs
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#

Listen 0.0.0.0:83

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup

</IfModule>
</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName subdominio.no-ip.org:83

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/share/htdocs"
#HE INTENTADO CAMBIANDO LA RUTA Y NADA a #DocumentRoot"/www/web"                                                    


#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/share/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "/var/log/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel debug

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "/var/log/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "/var/log/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/usr/share/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock /var/log/cgisock
</IfModule>

#
# "/usr/share/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/usr/share/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/apache/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
MIMEMagicFile /etc/apache/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
EnableSendfile off

# Supplemental configuration
#
# The configuration files in the /etc/apache/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include /etc/apache/extra/httpd-mpm.conf

# Multi-language error messages
#Include /etc/apache/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include /etc/apache/extra/httpd-autoindex.conf

# Language settings
#Include /etc/apache/extra/httpd-languages.conf

# User home directories
#Include /etc/apache/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include /etc/apache/extra/httpd-info.conf

# Virtual hosts
#Include /etc/apache/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include /etc/apache/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include /etc/apache/extra/httpd-dav.conf

# Various default settings
#Include /etc/apache/extra/httpd-default.conf

# Secure (SSL/TLS) connections
#Include /etc/apache/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
#<IfModule ssl_module>
#SSLRandomSeed startup builtin
#SSLRandomSeed connect builtin
#</IfModule>


Despues aplico correctamente:

Código: [Seleccionar]
apachectl -l start

Y nada, no puedo acceder ni por local ni remotamente.

Código: [Seleccionar]
netstat -plant

netstat: showing only processes with your user ID
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      1474/smbd
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      1437/uhttpd
tcp        1      0 0.0.0.0:8083            0.0.0.0:*               LISTEN      5280/httpd
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1534/dnsmasq
tcp        0      0 0.0.0.0:8022            0.0.0.0:*               LISTEN      982/dropbear
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      1474/smbd
tcp        0      0 192.168.10.1:xx (ssh-local)       192.168.10.143:54456    ESTABLISHED 1799/dropbear
tcp        0      0 192.168.10.1:xx (luci-local)       192.168.10.143:54487    ESTABLISHED 1437/uhttpd
tcp      321      0 192.168.10.1:8083       192.168.10.143:54545    ESTABLISHED -
tcp        0      0 :::5000                 :::*                    LISTEN      1798/miniupnpd
tcp        0      0 :::139                  :::*                    LISTEN      1474/smbd
tcp        0      0 :::53                   :::*                    LISTEN      1534/dnsmasq
tcp        0      0 :::8022                 :::*                    LISTEN      982/dropbear
tcp        0      0 :::445                  :::*                    LISTEN      1474/smbd

Código: [Seleccionar]
root@white:~# netstat -anp | grep CLOSE_WAIT

tcp      322      0 192.168.10.1:83       192.168.10.143:54545    CLOSE_WAIT  -


NOTA:
el acceso a mi OPENWRT en red local es 192.168.10.1
el acceso a mi OPENWRT remoto es con mi IP Publica y con un dominio NOIP con DDNS activado funcioanando en LUCI y SSH

un saludo¡¡

« Última modificación: 12-02-2015, 14:07 (Jueves) por CCCP »

Joseba30

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #1 en: 11-02-2015, 16:00 (Miércoles) »
Hola, no se que puede ser pero yo te digo lo que haria,

paro el apache
Código: [Seleccionar]
apachectl stopcorrigo las comillas (o las dos o ninguna) de tu httpd.conf
Código: [Seleccionar]
ServerRoot "/usr/share/htdocs
cambio el nombre de la maquina  de nuevo en httpd.conf
Código: [Seleccionar]
ServerName subdominio.no-ip.org:83por
Código: [Seleccionar]
ServerName 192.168.1.10:83
no recuerdo si era necesario poner el puerto, por supuesto que sea la ip de tu maquina, finalmente cambiaria
Código: [Seleccionar]
LogLevel debugpor
Código: [Seleccionar]
LogLevel error
por que es mas que evidente que ni has mirado el log haciendo un
Código: [Seleccionar]
cat /var/log/error_logque lo pondran para algo, luego inicias
Código: [Seleccionar]
apachectl starte intentas acceder, si lo permite, tienes un error de resolucion o dns o ruta, seria configurar debidamente el hostame de tu maquina, si es que no, pues lee el log a ver, que siempresd es buena idea.


Y para la proxima puedes recortar el tochaco que has pegado faciendo
Código: [Seleccionar]
grep -v '#' /etc/apache/httpd.confque te deja solo las opciones activas y es mas facil de leer para ayudarte a desfacer el entuerto.
« Última modificación: 11-02-2015, 16:08 (Miércoles) por Joseba30 »

CCCP

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #2 en: 11-02-2015, 16:40 (Miércoles) »
Funciona¡. Perfecto Joseba30. El error estaba en las rutas de ServerRoot y DocumentRoot.
Curiosamente si elimino la linea ServerName tb funciona

Código: [Seleccionar]
ServerRoot "/usr/share/htdocs"
Código: [Seleccionar]
ServerName 192.168.1.10:83

Y muy buena explicación. me apunto lo del log, que si los suelo mirar pero no sabia como activarlo y sobre todo esto:

Código: [Seleccionar]
grep -v '#' /etc/apache/httpd.conf
Gracias¡¡¡

Edito: por supuesto funciona en local y en remoto¡
« Última modificación: 11-02-2015, 17:13 (Miércoles) por CCCP »

CCCP

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #3 en: 11-02-2015, 16:54 (Miércoles) »
Mi idea es implementar un LAMP de modo que creo que irán surgiendo más dudas.
Con permiso del foro la siguiente cuestión que se me plantea es la siguiente:

No inicia automáticamente Apache al reiniciar el router.

Configuración:siguiendo el hilo http://wiki.openwrt.org/doc/howto/http.apache

Creo el archivo "apache" en la ruta /etc/init.d duplicando un archivo existente y poniendo el siguiente script:

vi /etc/init.d/apache
 
Código: [Seleccionar]
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org

START=10
STOP=15

start() {
echo launch apache
# commands to launch application
apachectl start
}

restart() {
echo re-start apache
# commands to launch application
apachectl restart
}

stop() {
echo stop apache
# commands to kill application
apachectl stop
}

Aplico

Código: [Seleccionar]
chmod +x /etc/init.d/apache
Código: [Seleccionar]
/etc/init.d/apache enable reinicio y nada. No arranca apache. Tengo que hacerlo a mano. "apachectl start"

NOTA: tb he provado a activar el arranque desde LUCI (activar) y nada.

¿Alguna idea? ¿Qué hago mal?
Por supuesto que gracias de antemano. Voy avanzando según me vaís aclarando dudas¡¡

vk496

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #4 en: 11-02-2015, 17:09 (Miércoles) »
No inicia automáticamente Apache al reiniciar el router.

Buenas

No he tenido tiempo para leer tu hilo, pero te comento una experiencia que puede ayudarte. Algunos programas ponen pegas cuando son ejecutados como root (o cuando no lo son). En mi caso particular, me acuerdo que znc me daba problemas al ejecutarlo como root. Para hacerlo funcionar, tenia que arrancarlo con parámetros extra que permitía obviar ese aspecto.

Desconozco si Apache tiene algo parecido, pero puede que te ayude saberlo. Yo me tiré unas cuantas horitas en darme cuenta  ;D ;D

Salu2

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2247
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #5 en: 11-02-2015, 17:32 (Miércoles) »
Puede que estés iniciando el Apache antes de que estén preparadas las interface de red.
¿Por qué no pruebas a aumentar el START=10 a START=90, para que tarde más en iniciarse?
La red se inicia en 40, y el firewall en 50, así que debiera estar por encima de esos valores.

Estados de arranque: http://wiki.openwrt.org/doc/techref/process.boot

Joseba30

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #6 en: 12-02-2015, 00:30 (Jueves) »
Nuevamente sin saber exactamente que puede ser, yo haria:

tras iniciar, paro y reinicio apache mediate init
Código: [Seleccionar]
/etc/init.d/apache stop
/etc/init.d/apache start

Si arranca es que inicia demasiado prontro, pasalo a START=97  por ejemplo, o añade al script algo como sleep 20
Código: [Seleccionar]
start() {
echo launch apache
# commands to launch application
                sleep 20
apachectl start
}

que no arranca, el eterno problema de permisos, apache arranca con un usuario y grupo realmente muy limitados y linux es particularmente picajoso en impedir que un programa con permisos limitados acceda a los directorios, en realidad eso es bueno pero a veces te hace la pascua,  lista el document root
Código: [Seleccionar]
ls -la /usr/share/htdocs
ls -la /usr/share
y verifica propietario y grupo y permisos del listado
Código: [Seleccionar]
drw-r--r--   1 root root      blablabla /usr/share/htdocseso es, dueño root, grupo root, las letras son la clave la primera d es directorio, y luego en grupos de tres usuario grupo y resto del mundo, es decir el usuario tiene permiso de lectura r escritura w pero no ejecucion - el grupo solo lectura y el restolmundo solo lectura.

Antes has usado chmod para darle permiso de ejecucion , de ser ese el problema o bien das permisos generales o cambias el grupo del directorio o  cambias el usuario y grupo en el que se inicia apache en httpd.conf Chmod y chown son tus amigos.

CCCP

  • Visitante
Re: Apache en Openwrt - Solucionar acceso local y remoto (httpd close_wait)
« Respuesta #7 en: 12-02-2015, 00:47 (Jueves) »
Funciona¡¡
Efectivamente Tki2000 y Joseba30 estabais en lo cierto.
Apache se levanta tras reinicio poniéndole una latencia a START=90
Tki2000 has dado en el clavo. Y Joseba30 me apunto lo de los permisos¡

Puede que estés iniciando el Apache antes de que estén preparadas las interface de red.
¿Por qué no pruebas a aumentar el START=10 a START=90, para que tarde más en iniciarse?
La red se inicia en 40, y el firewall en 50, así que debiera estar por encima de esos valores.

Estados de arranque: http://wiki.openwrt.org/doc/techref/process.boot

Sois una makina.
GraciAS
« Última modificación: 12-02-2015, 00:48 (Jueves) por CCCP »

CCCP

  • Visitante
Buenas de nuevo. Era de esperar.

Estado actual: Corriendo en local y remoto Apache, PHP5, y MySQL
No funciona: phpmyadmin
Problema: Página en blanco.(http://ip-local--ip-remota:puerto/phpmyadmin)

He mirado bastante en Google y me he vuelto picha.

Pasos dados:

Instalo PHP.

Código: [Seleccionar]
opkg list php*
opkg update
opkg install php5 php5-cgi

Edito vi /etc/php.ini
TEST OK
Puedo entrar en un index.php

Instalo MySQL

Código: [Seleccionar]
opkg update
opkg install libpthread libncurses libreadline mysql-server 
sed -i 's,^datadir.*,datadir         = "/srv/mysql",g' /etc/my.cnf
sed -i 's,^tmpdir.*,tmpdir          = "/tmp",g' /etc/my.cnf 
mkdir -p /srv/mysql
mysql_install_db --force 
/etc/init.d/mysqld start
/etc/init.d/mysqld enable 
mysqladmin -u root password 'new-password'

Pongo pass a user root

Habilito Mysql en la instalación PHP

Código: [Seleccionar]
opkg update opkg install php5-mod-mysql
sed -i 's,;extension=mysql.so,extension=mysql.so,g' /etc/php.ini

Edito php.ini para la configuracion de la sección MySQL

---------------------configuración específica-------------------------
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port = puerto diferente a 3306=xxxx
mysql.default_socket = /tmp/run/mysqld.sock ¿Correcto?
mysql.default_host = 192.168.10.1 ¿Ip local, correcto?
mysql.default_user = root
mysql.default_password = Password
mysql.connect_timeout = 60
mysql.trace_mode = Off
----------------------------------------------------------------------

Cambio la configuración de MySQL: vi /etc/my.cnf

----------------------------------------------------------------------
[client]
port      = puerto cambiado del 3306=xxxx
socket   = /var/run/mysqld.sock Es diferente de la confi de php.ini (/tmp/run/mysqld.sock ), ¿correcto?

[mysqld]
user      = root
socket   = /var/run/mysqld.sockEs diferente de la confi de php.ini (/tmp/run/mysqld.sock ), ¿correcto?
port      = 3307
basedir   = /usr

datadir      = "/srv/mysql"

tmpdir       = "/tmp"

skip-external-locking

bind-address   = 192.168.10.1

key_buffer      = 16M
max_allowed_packet   = 16M
thread_stack      = 192K
thread_cache_size       = 8

[mysqldump]
quick
quote-names
max_allowed_packet   = 16M

[mysql]

[isamchk]
key_buffer      = 16M
----------------------------------------------------------------------

Resultado: OK si conecto por consola
mysql -u root -p


AQUÍ VIENE EL PROBLEMA------------------------------------

phpmyadmin

Bajo las fuentes, las descomprimo, subo la carpeta phpMyAdmin-4.3.9-all-languages al server a la ruta:
/usr/share/htdocs
renombro la carpera como phpmyadmin
/usr/share/htdocs/phpmyadmin
Intento acceder por http//:ip:(puerto http cambiado del 80)/phpmyadmin
Resultado: error.....line 177
Solución: instalo mbstring
Intento acceder por http//:ip:(puerto http cambiado del 80)/phpmyadmin
Resultado: Página en blanco

Cosas que he intentado:

descomentar en php.ini
Código: [Seleccionar]
extension=mysqli.so
extension=mbstring.so

Editar configuración de phpmyadmin /usr/share/htdocs/phpmyadmin/config.inc.php

--------------------------------------------------------------------------------
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use setup/
 *
 * All directives are explained in documentation in the doc/ folder
 * or at <http://docs.phpmyadmin.net/>.
 *
 * @package PhpMyAdmin
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'coockie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '192.168.10.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

/*
 * phpMyAdmin configuration storage settings.
 */

/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = '192.168.10.1';
$cfg['Servers'][$i]['controlport'] = 'XXXX cambiado del 3306';
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'password';


/* 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]['table_uiprefs'] = 'pma__table_uiprefs';
// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
// $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

/**
 * Whether to display icons or text or both icons and text in table row
 * action segment. Value can be either of 'icons', 'text' or 'both'.
 */
//$cfg['RowActionType'] = 'both';

/**
 * Defines whether a user should be displayed a "show all (records)"
 * button in browse mode or not.
 * default = false
 */
//$cfg['ShowAll'] = true;

/**
 * Number of rows displayed when browsing a result set. If the result
 * set contains more rows, "Previous" and "Next".
 * default = 30
 */
//$cfg['MaxRows'] = 50;

/**
 * disallow editing of binary fields
 * valid values are:
 *   false    allow editing
 *   'blob'   allow editing except for BLOB fields
 *   'noblob' disallow editing except for BLOB fields
 *   'all'    disallow editing
 * default = blob
 */
//$cfg['ProtectBinary'] = 'false';

/**
 * Default language to use, if not browser-defined or user-defined
 * (you find all languages in the locale folder)
 * uncomment the desired line:
 * default = 'en'
 */
//$cfg['DefaultLang'] = 'en';
//$cfg['DefaultLang'] = 'de';

/**
 * default display direction (horizontal|vertical|horizontalflipped)
 */
//$cfg['DefaultDisplay'] = 'vertical';


/**
 * How many columns should be used for table display of a database?
 * (a value larger than 1 results in some information being hidden)
 * default = 1
 */
//$cfg['PropertiesNumColumns'] = 2;

/**
 * Set to true if you want DB-based query history.If false, this utilizes
 * JS-routines to display query history (lost by window close)
 *
 * This requires configuration storage enabled, see above.
 * default = false
 */
//$cfg['QueryHistoryDB'] = true;

/**
 * When using DB-based query history, how many entries should be kept?
 *
 * default = 25
 */
//$cfg['QueryHistoryMax'] = 100;

/**
 * Should error reporting be enabled for JavaScript errors
 *
 * default = 'ask'
 */
//$cfg['SendErrorReports'] = 'ask';

/*
 * You can find more configuration options in the documentation
 * in the doc/ folder or at <http://docs.phpmyadmin.net/>.
 */
?>

--------------------------------------------------------------------------------

Nota:
accedo por un puerto http cambiado del 80 a otro (funcionando en LAMP)
Intento cambiar tb el puerto por defecto de Mysql

¿Como hago para acceder a phpmyadmin via web?

Gracias de nuevo y perdon por el tocho pero no se por donde casca.
Un saludo

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2247
El socket de php.ini y de my.cnf debe coincidir, o no funcionará. Ya me rasqué la cabeza con esto al instalar el codeka...

Yo no tengo instalado el apache en el router.
Desde un phpmyadmin remoto sí accedo a mysql en el router.
¿Es necesario que tengas el apache? Yo tengo el php con uhttpd y me va bastante bien... En vez de LAMP tengo LUMP  ;D (Sí, hay juego de palabras)

Los módulos que tengo cargados de php son estos, pero a lo mejor hace falta alguno más para el phpmyadmin en local.
Código: [Seleccionar]
php5 - 5.4.23-1
php5-cgi - 5.4.23-1
php5-mod-ftp - 5.4.23-1
php5-mod-gd - 5.4.23-1
php5-mod-mbstring - 5.4.23-1
php5-mod-mysql - 5.4.23-1
php5-mod-session - 5.4.23-1

Por cierto, utilizo adminer en lugar de phpmyadmin para administrar las bases de datos. Es mucho más ligero y podemos hacer lo mismo.

Tengo traspapelado un tutorial, que iba a servir para instalar codeka en openwrt (extroot,php,mysql,adminer,codeka). Lo instalé y funciona, pero da la casualidad de que a los desarrolladores de openwrt, no les ha dado por meter los parches para compilar php-gd con soporte de fuentes, y hay partes de codeka que no funcionan. Ahora tengo que reunir fuerzas para recompilar todo el php, incorporando los parches para las fuentes, así que no sé cuándo lo haré (lo de recompilar), ni si lo haré.

Lo mismo vuelvo a retomar el tuto y lo publico si hay interés, menos la parte de codeka.


« Última modificación: 12-02-2015, 18:45 (Jueves) por Tki2000 »

CCCP

  • Visitante
Socket

El socket de php.ini y de my.cnf debe coincidir, o no funcionará.

He puesto en ambos el mismo y nada. Por cierto ¿cual es la diferencia en poner?
/tmp/run/mysqld.sock 
/var/run/mysqld.sock

Error log

Haciendo uso de la propuesta de Joseba30, esto son los errores al intentar acceder a phpmyadmin

cat /var/log/error_log
Código: [Seleccionar]
[Fri Feb 13 02:12:58 2015] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1j configured -- resuming normal operations
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/gd.so' - File not found in Unknown on line 0
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143]
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143]
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143] PHP Warning:  Module 'mysql' already loaded in Unknown on line 0
No mismo si accedo desde remoto

Sigue saliendo la página en blanco al acceder a phpmyadmin. Y no se interpretar los errores.

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2247
Socket

El socket de php.ini y de my.cnf debe coincidir, o no funcionará.

He puesto en ambos el mismo y nada. Por cierto ¿cual es la diferencia en poner?
/tmp/run/mysqld.sock  
/var/run/mysqld.sock

Error log

Haciendo uso de la propuesta de Joseba30, esto son los errores al intentar acceder a phpmyadmin

cat /var/log/error_log
Código: [Seleccionar]
[Fri Feb 13 02:12:58 2015] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1j configured -- resuming normal operations
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/gd.so' - File not found in Unknown on line 0
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143]
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143]
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143] PHP Warning:  Module 'mysql' already loaded in Unknown on line 0
No mismo si accedo desde remoto

Sigue saliendo la página en blanco al acceder a phpmyadmin. Y no se interpretar los errores.


Por un lado te está diciendo que le falta el módulo php-mod-gd, que lo tengo listado entre los necesarios para la instalación.

Yo borraría esto:
Código: [Seleccionar]
mysql.default_host = 192.168.10.1 ¿Ip local, correcto?
mysql.default_user = root
mysql.default_password = Password
Es una brecha de seguridad asumir usuarios al acceder con usuarios y contraseña por defecto. Cualquier aplicación que acceda, debe proporcionar su propio usuario y contraseña. phpmyadmin lo configura es su fichero de configuración.

Como bind-address prueba 0.0.0.0

Yo probaría la siguiente configuración en phpmyadmin

Código: [Seleccionar]
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';

Pero para ello te hace falta el driver php-mod-mysqli. (Pero como digo más adelante, no es necesario instalar este driver)
Hay 3 drivers para acceder a mysql desde PHP,
Código: [Seleccionar]
php-mod-mysql
php-mod-mysqli
php-mod-pdo-mysql

En principio, cualquiera de los tres te puede servir, si la aplicación que los utiliza se puede configurar. Hay aplicaciones que te obligan a tener instalado uno en concreto. Yo tengo sólo el php-mod-mysql, pero he probado los demás y también funcionan.

Voy a intentar instalar phpmyadmin en el router y comento resultados.



Edito: funcionando perfectamente con el driver simple php-mod-mysql, y acceso tanto por puerto TCP como con socket local:
He probado estas 3 configuraciones :
Código: [Seleccionar]
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = 'elquetengasparaacceder';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

o bien:

Código: [Seleccionar]
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

o bien:

Código: [Seleccionar]
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = '192.168.1.1';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

 
« Última modificación: 13-02-2015, 09:30 (Viernes) por Tki2000 »

CCCP

  • Visitante
Muchas gracias por lo detallado y las menciones previas.
Me he tomado mi tiempo y no funciona en mi configuración:
Pasos dados y soluciones parciales:


He puesto la misma ruta a socket tanto en php.ini como en my.cnf:
/var/run/mysqld.sock

He instalado:
Código: [Seleccionar]
php5 5.4.27-1
php5-cgi 5.4.27-1
php5-mod-ftp 5.4.27-1
php5-mod-gd 5.4.27-1
php5-mod-mbstring 5.4.27-1
php5-mod-mysql 5.4.27-1
php5-mod-session

Con ello he arreglado el error:
Código: [Seleccionar]
[Fri Feb 13 02:14:42 2015] [error] [client 192.168.10.143] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/gd.so' - File not found in Unknown on line 0
OK

Me seguian apareciendo estos errores:

Código: [Seleccionar]
[Sat Feb 14 14:31:26 2015] [error] [client 192.168.10.143] PHP Warning:  Module 'gd' already loaded in Unknown on line 0
[Sat Feb 14 14:31:26 2015] [error] [client 192.168.10.143] PHP Warning:  Module 'mbstring' already loaded in Unknown on line 0
[Sat Feb 14 14:31:26 2015] [error] [client 192.168.10.143] PHP Warning:  Module 'mysql' already loaded in Unknown on line 0

proviene de descomentar la extensiones en php.ini
Código: [Seleccionar]
extension=gd.so
extension=mbstring.so
extension=mbstring.so
Lo he hecho porque en algunos tutos o foros aparece que el problema de la página en blanco se debe a no tener habilitadas las extendiones.

Solución: he vuelto a quitarlas y el error ha desaparecido de cat /var/log)error_log

Código: [Seleccionar]
;extension=gd.so
;extension=mbstring.so
;extension=mbstring.so

OK. Creo. ¿Es correcto quitarlo no? Entiendo que si, dado que desaparece el warning

He borrado:
Código: [Seleccionar]
mysql.default_host = 192.168.10.1
mysql.default_user = root
mysql.default_password = Password

He probado las 3 configuraciones:

Resultado: PÁGINA EN BLANCO
Código: [Seleccionar]
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = 'elquetengasparaacceder';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

o bien:

Código: [Seleccionar]
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

o bien:

Código: [Seleccionar]
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = '192.168.1.1';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

NOTAS---------------------------------------

Estoy tirando con php5-mod-mysql
No he instalado php-mod-mysqli, php-mod-pdo-mysql

Puedo crear un BD desde consola:
Código: [Seleccionar]
mysql -u root -p
mysql> CREATE DATABASE test;
mysql> GRANT ALL PRIVILEGES ON test.* TO 'usuario'@'localhost' IDENTIFIED BY 'clave';
Puedo verla desde consola pero no puedo conectar desde un cliente.

Navego hacia apache y php por HTTP por un puerto cambiado y tb  he cambiado el puerto por defecto de MySQL al 3307. Esto es asi porque tengo otro server LAMP en la misma LAN y en teoría esta bien configurado. Así que el problema esta en php, phpmyadmin, o mysql.

No puedo habilitar el php_error. ¿Hace falta, o los errores de PHP se representan en error_log?. Si me decis que no, espeficco que es lo que hago.

Ahhhhhhhhhhhhhh¡ ¿Que leches hago mal?
« Última modificación: 14-02-2015, 14:58 (Sábado) por CCCP »

CCCP

  • Visitante
Bueno... siguiendo la recomendación:

He podido hacer andar Adminer:

Ento en http://local-remoto:puerto_cambiado/adminer.php
Me logueo correctamente contra el user y pass configurado en la instalación de MyQSL
Veo las BD creadas desde consola y su user, privilegios,...
No puedo crear BD, ni cambiar privilegios. resultado: PAGINA EN BLANCO


¿Puede haber una pauta comun entre el phpmyadmin y el adminer en este aspecto.
puerto 3307 modificado, privilegios, rutas,...???
« Última modificación: 14-02-2015, 17:42 (Sábado) por CCCP »

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2247
Bueno... siguiendo la recomendación:

He podido hacer andar Adminer:

Ento en http://local-remoto:puerto_cambiado/adminer.php
Me logueo correctamente contra el user y pass configurado en la instalación de MyQSL
Veo las BD creadas desde consola y su user, privilegios,...
No puedo crear BD, ni cambiar privilegios. resultado: PAGINA EN BLANCO


¿Puede haber una pauta comun entre el phpmyadmin y el adminer en este aspecto.
puerto 3307 modificado, privilegios, rutas,...???


¿Dónde tienes el datadir y tmpdir de mysql?

CCCP

  • Visitante
Si, me había fijado y me da que está mal, por defecto, lo tengo en:

my.conf

Código: [Seleccionar]
basedir = /usr
tmpdir         = "/tmp"

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2247
Re: LAMP en Openwrt - Soluciones (httpd close_wait, arranque, PHP,MySQL,phpmyadmin)
« Respuesta #16 en: 18-02-2015, 21:08 (Miércoles) »
Si, me había fijado y me da que está mal, por defecto, lo tengo en:

my.conf

Código: [Seleccionar]
basedir = /usr
tmpdir         = "/tmp"

He hecho un tutorial para instalar un pequeño servidor LAMP en openwrt.
Echale un vistazo, por si te sirve de ayuda en la configuración: https://foro.seguridadwireless.net/openwrt/(tutorial)-servidor-lamp-http-mysql-php/

CCCP

  • Visitante
Si, me había fijado y me da que está mal, por defecto, lo tengo en:

my.conf

Código: [Seleccionar]
basedir = /usr
tmpdir         = "/tmp"

He hecho un tutorial para instalar un pequeño servidor LAMP en openwrt.
Echale un vistazo, por si te sirve de ayuda en la configuración: https://foro.seguridadwireless.net/openwrt/(tutorial)-servidor-lamp-http-mysql-php/

A priori tiene una pinta estupenda. Lo voy a revisar. Me alegro haber incentivado tu trabajo y desde luego tu predisposición magnífica.
Gracias y salud.