Page 1
Standard

Habilitar query log en MySQL

Editar el archivo /etc/mysql/my.cnf y agregar al final del archivo:

[mysqld]
general_log=on
general_log_file=/var/log/mysql/query.log

Reiniciar el servicio

service mysql restart

Revisamos la salida

tail -f /var/log/mysql/query.log
more
Standard

Cambiar la contraseña root de MySQL en Issabel

A continuación muestro como cambiar la contraseña root de Mysql en Issabel

Detener el servicio mysql

systemctl stop mariadb

Iniciamos el modo seguro:

mysqld_safe --skip-grant-tables &

Hacemos un login a MySQL sin password

mysql -u root

Actualizamos la contraseña

update mysql.user set password=PASSWORD("1notfound1") where user='root';

Cargamos los privilegios / permisos y salimos de la sesión:

Iniciamos el servicio
systemctl start mariadb
 y Listo!
more
Standard

Loguearse por SSH sin ingresar contraseña

Conectarse de un Equipo A con IP 192.168.1.10 a otro Equipo B con direccion ip 192.168.2.20 sin ingresar la contraseña.

  1. Crear clave de autenticación en el Equipo A 192.168.1.10

ssh-keygen -t rsa

No ingresar contraseña

  1. Copiar la clave pública desde el Equipoo A al Equipo B
cat ~/.ssh/id_rsa.pub | ssh demo@192.168.2.20 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
ssh-copy-id demo@192.168.2.20
  1.  Conectar de Equipo A a Equipo B sin contraseña
ssh demo@192.168.2.20

more
Standard

No se puede instalar PHP en Debian

Cuando se ejecuta sudo apt-get install php7.0 aparece el error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php : Depends: php7.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Se debe ejecutar el siguiente comando para verificar que PPAs tenemos configurados:

LC_ALL=C apt policy

Si la salida es esta:

 500 http://ppa.launchpad.net/ondrej/php/ubuntu disco/main amd64 Packages
     release v=19.04,o=LP-PPA-ondrej-php,a=disco,n=disco,l=***** The main PPA fo                                                                             r supported PHP versions with many PECL extensions *****,c=main,b=amd64
     origin ppa.launchpad.net

Quiere decir que hemos roto el sistema agregando fuentes extranjeras, hay que eliminar las fuentes php del sourcelist:

cd /etc/apt/sources.list.d/

Eliminar las fuentes php:

rm ondrej-ubuntu-php-disco.list
rm ondrej-ubuntu-php-disco.list.save
rm php7.3.list
rm php7.3.list.save

Actualizar e instalar

apt-get update
apt-get install php

Y listo.

more
Standard

gpg: failed to start the dirmngr ‘/usr/bin/dirmngr’: No such file or directory

Al querer agregar un repositorio aparece el error:

gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory

Acompañado de:

gpg: connecting dirmngr at '/tmp/tmpyq7kwe2x/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr

Para solucionarlo hay que instalar el paquete dirmgr:

sudo apt-get install dirmngr

y listo.

more
Standard

Solución: locale: Cannot set LC_ALL to default locale: No such file or directory

Cuando queremos instalar algo desde la terminal aparece el error:

apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
Reading changelogs... Done
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:en",
	LC_ALL = (unset),
	LC_TIME = "es_CO.UTF-8",
	LC_MONETARY = "es_CO.UTF-8",
	LC_ADDRESS = "es_CO.UTF-8",
	LC_TELEPHONE = "es_CO.UTF-8",
	LC_NAME = "es_CO.UTF-8",
	LC_MEASUREMENT = "es_CO.UTF-8",
	LC_IDENTIFICATION = "es_CO.UTF-8",
	LC_NUMERIC = "es_CO.UTF-8",
	LC_PAPER = "es_CO.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory

Para solucionarlo instalamos la codificación español:

sudo locale-gen en_US.UTF-8

Luego reconfiguramos:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Y el error desaparece.

more
Standard

Solucionar error: W: GPG error: ….: The following signatures couldn’t be verified because the public key is not available:

Al querer agregar el repositorio de php me aparece el error:

W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu disco InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6

Nos muestra que la llave pública no está disponible.

Lo que debemos hacer es buscar esta clave pública en el sistema. Obtenerla del mismo mensaje de error, al final: NO_PUBKEY 4F4EA0AAE5267A6

y usarla con el siguiente comando:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6

Y Listo.

more
more
mssql-php
Standard

Instalar drivers de Microsoft PHP para SQL Server en Ubuntu 16.04

En este tutorial veremos cómo instalar PHP para SQL Server, en este ejemplo usaremos la versión 7.0, si se desea la versión 7.2 sólo es reemplazar, usaré Ubuntu 16.04 pero  puede funcionar con otras versiones.

sudo su 
add-apt-repository ppa:ondrej/php -y 
apt-get update 
apt-get install php7.0 php7.0-dev php7.0-xml -y --allow-unauthenticated

Prerequisitos:

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 17.10
curl https://packages.microsoft.com/config/ubuntu/17.10/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Drivers PHP para Microsoft SQL Server:

sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
exit

Apache:

sudo su
apt-get install libapache2-mod-php7.0 apache2
a2dismod mpm_event
a2enmod mpm_prefork
a2enmod php7.0
echo "extension=pdo_sqlsrv.so" >> /etc/php/7.0/apache2/conf.d/30-pdo_sqlsrv.ini
echo "extension=sqlsrv.so" >> /etc/php/7.0/apache2/conf.d/20-sqlsrv.ini
exit

Reiniciar apache

sudo service apache2 restart

Fuente:

https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017#installing-the-drivers-on-ubuntu-1604-and-1710

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

more
Standard

Personalizar error 403

En la raíz se crea el archivo .htaccess con las ip a las cuales se les permite el acceso y la url del archivo que se va a abrir si no está dentro de las ip permitidas.

sudo nano .htaccess
<RequireAny>
 Require ip 190.248.159.226
 Require ip 190.248.159.227
</RequireAny>
ErrorDocument 403 /error/403.php

Se debe crear la carpeta error y dentro de ella su respectivo .htaccess

<RequireAll>
    Require all granted  
</RequireAll>

Dentro de la carpeta error se crea el archivo 403.php con el siguiente contenido:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1"/>
 <script src="//use.fontawesome.com/84c9ca0cf8.js"></script>
 <title>403 Acceso Denegado</title>

<style type="text/css">
 @import url('//fonts.googleapis.com/css?family=Roboto');
 body {
 background: #2e739a;
 color: #D7D7D7;
 font: 16px/1.3 "Roboto", sans-serif;
 }
 header {
 width: 100%;
 margin:0px auto;
 }
 h1 {
 text-align: center;
 color:#D7D7D7;
 font: 30px/1 "Roboto";
 text-transform: uppercase;
 margin: 5% auto 5%;
 margin-bottom: 35px;
 }

article { display: block; text-align: center; width: 650px; margin: 10px auto; }

@media screen and (max-width: 720px) {
 article { display: block; text-align: center; width: 450px; margin: 0 auto; }
 h1 { font: 70px/1 "Roboto";}
 .wrap {margin-top: 50px;}
 }

@media screen and (max-width: 480px) {
 article { display: block; text-align: center; width: 300px !important; margin: 0 auto; }
 h1 { font: 50px/1 "Roboto";}
 .wrap {margin-top: 50px;}

}
 </style>

<!--[if IE]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

</head>
<body>
<div class="wrap">
 <article>
 <header>
 <h1 id="fittext1">Error 403<i class="fa fa-exclamation-triangle fa-fw"></i></h1>
 </header>
 <p id="fittext2">Acceso Denegado </br> Su IP <?php echo $_SERVER['REMOTE_ADDR']; ?> no está autorizada para ver este contenido </br> Por favor contacte al administrador</p>
 </article>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/FitText.js/1.2.0/jquery.fittext.js"></script>
<script type="text/javascript">
 $("#fittext1").fitText(1.1);
 $("#fittext2").fitText(1.5);
</script>
</body>
</html>
more