GNU/Linux >> Tutoriales Linux >  >> Ubuntu

Cómo instalar Matomo Web Analytics en Ubuntu 18.04 LTS

Matomo, anteriormente conocido como Piwik, es una aplicación de análisis web gratuita que se puede utilizar para realizar un seguimiento de las visitas en línea a uno o más sitios web y muestra informes sobre estas visitas para su análisis. Matomo viene con muchas características que incluyen Google AdWords, Facebook Ads, Yahoo! Marketing de búsqueda, API de seguimiento e informes, costo por clic (CPC) y muchos más.

En este tutorial, explicaré cómo instalar Matomo en el servidor Ubuntu 18.04 LTS.

Requisitos

  • Un servidor con Ubuntu 18.04 LTS.
  • Un usuario no root con privilegios sudo.

Instalar servidor LAMP

Matomo se ejecuta en el servidor web, está escrito en lenguaje PHP y usa MariaDB para almacenar sus datos. Por lo tanto, deberá instalar Apache, MariaDB, PHP y otros módulos PHP necesarios en su sistema.

Actualice el repositorio de Ubuntu e instale PHP junto con Apache y MariaDB con el siguiente comando:

sudo apt-get update -y
sudo apt-get install apache2 mariadb-server php7.2 libapache2-mod-php7.2 php7.2-common php7.2-sqlite php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip wget unzip git -y

Una vez que todos los paquetes estén instalados, inicie el servicio Apache y MariaDB y habilítelos para que se inicien en el momento del arranque con el siguiente comando:

sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mariadb
sudo systemctl enable mariadb

A continuación, deberá modificar el archivo php.ini. Puedes hacer esto con el siguiente comando:

sudo nano /etc/php/7.2/apache2/php.ini

Realice los siguientes cambios:

memory_limit = 256M
upload_max_filesize = 200M
max_execution_time = 360
date.timezone = Europe/Berlin

Guarde y cierre el archivo cuando haya terminado.

Configurar MariaDB

A continuación, deberá asegurar su instalación de MariaDB. Puede hacerlo ejecutando el siguiente script:

sudo mysql_secure_installation

Responda todas las preguntas como se muestra a continuación:

    Enter current password for root (enter for none):
    Set root password? [Y/n]: N
    Remove anonymous users? [Y/n]: Y
    Disallow root login remotely? [Y/n]: Y
    Remove test database and access to it? [Y/n]:  Y
    Reload privilege tables now? [Y/n]:  Y

Una vez que MariaDB esté protegida, inicie sesión en el shell de MariaDB:

mysql -u root

Cree una base de datos y un usuario con el siguiente comando:

MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> CREATE USER matomo;

A continuación, otorgue privilegios a la base de datos de Matomo con el siguiente comando:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON matomodb.* TO 'matomo'@'localhost' IDENTIFIED BY 'mypassword';

Reemplace la palabra 'mypassword' con una contraseña segura de su elección. A continuación, elimine los privilegios con el siguiente comando:

MariaDB [(none)]> FLUSH PRIVILEGES;

A continuación, salga de la consola de MariaDB con el siguiente comando:

MariaDB [(none)]> exit

Instalar Matomo

Primero, descargue la última versión de Matomo desde su sitio web oficial al directorio /tmp:

cd /tmp
wget https://builds.matomo.org/piwik.zip

A continuación, descomprima el archivo descargado con el siguiente comando:

unzip piwik.zip

Luego copie el directorio extraído al directorio raíz de Apache y otorgue los permisos adecuados:

sudo cp -r piwik /var/www/html/matomo
sudo chown -R www-data:www-data /var/www/html/matomo/
sudo chmod -R 755 /var/www/html/matomo/

Finalmente, cree un archivo de configuración de Apache para Matomo con el siguiente comando:

sudo nano /etc/apache2/sites-available/matomo.conf

Agregue las siguientes líneas:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/matomo
     ServerName example.com

     <Directory /var/www/html/matomo/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
     CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined

</VirtualHost>

Reemplace example.com y la dirección de correo electrónico [email protected] con su propio nombre de dominio y dirección de correo electrónico. Guarde y cierre el archivo, luego habilite el archivo de host virtual y el módulo de reescritura de Apache con el siguiente comando:

sudo a2ensite matomo
sudo a2enmod rewrite

Reinicie el servicio web Apache para aplicar todos los cambios:

sudo systemctl restart apache2

Habilite SSL con Let's encrypt para Matomo

En este paso, habilitaremos SSL para Matomo mediante el uso de un certificado Let's encrypt SSL gratuito. El primer paso es instalar el certbot Let’s encrypt client que usaremos para obtener el certificado SSL.

sudo apt-get install certbot python-certbot-apache

Solicite el certificado SSL con este comando:

sudo certbot --apache

IMPORTANTE:El nombre de dominio o subdominio que utiliza para el sitio web de RoundCube debe ser accesible desde Internet para obtener un certificado SSL. Certbot le hará algunas preguntas ahora.

[email protected]: certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: a
-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: n
Which names would you like to activate HTTPS for?
-------------------------------------------------------------------------------
1: example.com
-------------------------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/matomo-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/matomo-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/matomo-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting vhost in /etc/apache2/sites-enabled/matomo.conf to ssl vhost in /etc/apache2/sites-available/matomo-le-ssl.conf
-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
-------------------------------------------------------------------------------
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2019-07-10. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

Ahora se puede acceder al Matomo vhost mediante https.

Acceder a Matomo

Ahora, abra su navegador web y escriba la URL https://example.com, será redirigido a la página de bienvenida de Matomo:

Ahora, haga clic en Siguiente botón. Debería ver la siguiente página:

Aquí, asegúrese de que se haya instalado todo el módulo requerido. Luego, haga clic en Siguiente botón. Debería ver la siguiente página:

Aquí, proporcione su base de datos y nombre de usuario de Matomo. Luego, haga clic en Siguiente botón. Debería ver la siguiente página:

Ahora, haga clic en Siguiente botón. Debería ver la siguiente página:

Aquí, proporcione su nombre de usuario y contraseña de administrador. Luego, haga clic en Siguiente botón. Debería ver la siguiente página:

Ahora, proporcione el nombre del sitio, la URL del sitio web. Luego, haga clic en Siguiente botón. Debería ver el código de seguimiento del sitio de Matomo en la siguiente página:

Ahora, haga clic en Siguiente botón. Una vez finalizada la instalación. Debería ver la siguiente página:

Ahora, haga clic en CONTINUAR A MATOMO botón. Debería ver la siguiente página:

Ahora, proporcione las credenciales de inicio de sesión del administrador y haga clic en INICIAR SESIÓN botón. Debería ver el panel de control de Matomo en la siguiente página:


Ubuntu
  1. Cómo instalar R en Ubuntu 18.04 LTS

  2. Cómo instalar R en Ubuntu 20.04 LTS

  3. Cómo instalar Redmine en Ubuntu 20.04 LTS

  4. Cómo instalar Matomo Web Analytics en Ubuntu 20.04

  5. Cómo instalar MariaDB en Ubuntu 22.04

Cómo instalar Matomo Web Analytics en Ubuntu 20.04

Cómo instalar MariaDB en Ubuntu 20.04 LTS

Cómo instalar MariaDB 10.6 en Ubuntu 20.04

Cómo instalar MariaDB 10.7 en Ubuntu 20.04

Cómo instalar Open Web Analytics en Ubuntu 18.04 LTS

Cómo instalar ERPNext en Ubuntu 20.04 LTS