Configuration de MariaDB LogRotate PHP ....
Find a file
2025-11-24 07:54:50 +00:00
README.md Actualiser README.md 2025-11-24 07:54:50 +00:00

Configuration de mon serveur Apache2/Proxy

Il traite nativement Wordpress ( PHP-FPM + MariaDB + Redis ) / Humhub ( PHP-FPM + MariaDB ) / GoAccess / Munin .

LogRotate

Je garde 120 jours de logs pour GoAccess

# cat /etc/logrotate.d/apache2
/var/log/apache2/*.log {
    daily
    missingok
    rotate 120
    compress
    delaycompress
    notifempty
    create 640 root adm
    sharedscripts
    prerotate
	if [ -d /etc/logrotate.d/httpd-prerotate ]; then
	    run-parts /etc/logrotate.d/httpd-prerotate
	fi
    endscript
    postrotate
	if pgrep -f ^/usr/sbin/apache2 > /dev/null; then
	    invoke-rc.d apache2 reload 2>&1 | logger -t apache2.logrotate
	fi
    endscript
}

Contab

GoAccess

0 1 * * * zcat -f /var/log/apache2/access* | /usr/local/bin/goaccess - -o /var/www/html/goaccess/index.html --log-format=COMBINED --keep-last=120

MariaDB

Attention j'ai beaucoup de RAM sur la VM ...

# cat /etc/mysql/mariadb.conf.d/50-server.cnf | grep -v "#" | grep -v "^$"
[server]
[mysqld]
skip-name-resolve
user                    = mysql
pid-file                = /run/mysqld/mysqld.pid
basedir                 = /usr
datadir                 = /var/lib/mysql
tmpdir                  = /tmp
lc-messages-dir         = /usr/share/mysql
lc-messages             = en_US
skip-external-locking
skip-name-resolve=ON
performance_schema=ON
query_cache_limit = 1024K
query_cache_min_res_unit = 2k
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
bind-address            = 127.0.0.1
key_buffer_size        = 24M
max_connections        = 200
expire_logs_days        = 10
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 2G
innodb_log_buffer_size = 256M
thread_cache_size = 16
query_cache_size = 0
query_cache_type = 0
tmp_table_size = 1024M
max_heap_table_size = 1024M
table_open_cache = 4096
table_definition_cache = 4096
join_buffer_size = 64M
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
[embedded]
[mariadb]
[mariadb-10.5]

Configuration de SYSCTL

Pas de swap c'est mieux pour MariaDB

# cat /etc/sysctl.conf  | grep -v "^#" | grep -v "^$"
vm.swappiness=0

Configuration de PHP-FPM

# cat /etc/php/8.4/fpm/pool.d/www.conf  | grep -v ";" | grep -v "^$"
[www]
user = www-data
group = www-data
listen = /run/php/php8.4-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 100
pm.start_servers = 40
pm.min_spare_servers = 20
pm.max_spare_servers = 60
pm.max_requests = 500