Mautic

De MochilaWiki
Ir para navegaçãoIr para pesquisar

Página do projeto

Instalação do Mautic em Ubuntu 16.04

Instalando dependências

sudo apt-get install nginx mariadb-server php7.0-fpm php7.0-xml \
unzip php7.0-imap php7.0-intl php7.0-zip php7.0-mcrypt php7.0-mysql \
php7.0-curl php7.0-mbstring php7.0-gd

Ajustes no PHP

É necessário ajustar:

memory_limit = 256M
upload_max_filesize = 64M
max_execution_time = 360
cgi.fix_pathinfo = 0
date.timezone = America/Sao_Paulo

Ajustante diretamente com Sed

sudo sed -i '389s/128/256/g' /etc/php/7.0/fpm/php.ini
sudo sed -i '809s/2/64/g' /etc/php/7.0/fpm/php.ini
sudo sed -i '368s/30/360/g' /etc/php/7.0/fpm/php.ini
sudo sed -i 's#;date.timezone =#date.timezone = America/Sao_Paulo#g' /etc/php/7.0/fpm/php.ini
sudo sed -i 's#;cgi.fix_pathinfo=1#cgi.fix_pathinfo = 0#g' /etc/php/7.0/fpm/php.ini

Configuração no Nginx

em /etc/nginx/sites-available/mautic

server {
    listen 80;

 server_name  quijaua.net www.quijaua.net;

 root /var/www/html/mautic;


    index index.html index.htm index.php;
    error_page 404 /index.php;

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log error;

    charset utf-8;

    # redirect index.php to root
    rewrite ^/index.php/(.*) /$1  permanent;

    # redirect some entire folders
    rewrite ^/(vendor|translations|build)/.* /index.php break;

    location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to index.html
        # one option: try_files $uri $uri/ /index.php$is_args$args;
        try_files $uri /index.php$is_args$args;
 		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

    # Deny everything else in /app folder except Assets folder in bundles
    location ~ /app/bundles/.*/Assets/ {
        allow all;
        access_log off;
    }
    location ~ /app/ { deny all; }

    # Deny everything else in /addons or /plugins folder except Assets folder in bundles
    location ~ /(addons|plugins)/.*/Assets/ {
        allow all;
        access_log off;
    }
    location ~ /(addons|plugins)/ { deny all; }

    # Deny all php files in themes folder
    location ~* ^/themes/(.*)\.php {
        deny all;
    }

    # Don't log favicon
    location = /favicon.ico {
    	log_not_found off;
    	access_log off;
    }

    # Don't log robots
    location = /robots.txt  {
    	access_log off;
    	log_not_found off;
    }

    # Deny yml, twig, markdown, init file access
    location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Deny all grunt, composer files
    location ~* (Gruntfile|package|composer)\.(js|json)$ {
        deny all;
        access_log off;
        log_not_found off;
    }

    #######################################
    ##  End Mautic Specific config #####
    #######################################

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
    location ~ \.php$ {
        # try_files $uri =403;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

               include snippets/fastcgi-php.conf;
               fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

#        fastcgi_pass unix:/var/run/php5-fpm.sock;
#        fastcgi_index index.php;
        include fastcgi_params;

        fastcgi_buffer_size 128k;
        fastcgi_buffers 256 16k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
}

E depois habilita o novo domínio

sudo ln -s /etc/nginx/sites-available/mautic /etc/nginx/sites-enabled/


Criando banco de dados

Ajuste as segurança do Mariadb com o comando mysql_secure_installation (tudo com Y)

create database mautic;
GRANT all ON mautic.* TO 'mautic'@'localhost' identified by 'sua_senha';
flush privileges;
quit

serviços

Reiniciando e colocando serviços LEMP na inicialização

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
sudo systemctl restart php7.0-fpm
sudo systemctl enable php7.0-fpm

Instalando Mautic

cd /tmp && wget https://www.mautic.org/download/latest
sudo mkdir /var/www/html/mautic
sudo unzip latest -d /var/www/html/mautic
sudo chown -R www-data:www-data /var/www/html/mautic/
cd /var/www/html/mautic/
sudo chmod -R g+w app/logs/
sudo chmod -R g+w app/cache
sudo chmod -R g+w app/config/
sudo chmod -R g+w media/files/
sudo chmod -R g+w media/images/
sudo chmod -R g+w media/dashboards/
sudo chmod -R g+w translations/

Configurações do Cron

(precisa testar isso)

sudo mkdir /var/log/cron
sudo touch /var/log/cron/mautic-lead-update
sudo touch /var/log/cron/mautic-campaign-update
sudo touch /var/log/cron/mautic-campaign-trigger
sudo chown -R ubuntu:ubuntu  /var/log/cron

rodando crontab -e

#cron
*/5 * * * * /usr/bin/php /var/www/mautic/app/console mautic:leadlists:update --env=prod >> /var/log/cron/mautic-lead-update 2>&1
*/5 * * * * /usr/bin/php /var/www/mautic/app/console mautic:campaigns:update --env=prod >> /var/log/cron/mautic-campaign-update 2>&1
*/5 * * * * /usr/bin/php /var/www/mautic/app/console mautic:campaigns:trigger --env=prod >> /var/log/cron/mautic-campaign-trigger 2>&1

Referências

plataforma complementar para criação de template de newsletter