apache2.conf
To diagnose and solve the recurring Apache memory issue on your 2 GB RAM + 2 GB swap Debian 13 VPS, let's break this down systematically.
From your logs:
status=1/FAILURE
Run:
tail -n 100 /var/log/apache2/error.log
Look for:
Out of memory
mod_php
mod_perl
malloc
dmesg | grep -i "oom\|kill"
If the kernel killed Apache, you'll see entries like:
Out of memory: Kill process 12345 (apache2) score 900 or sacrifice child
Use htop, glances, or sar to track memory usage before the next crash. Example:
htop
glances
sar
apt install htop htop
F6
MEM%
echo "0 3 * * * systemctl restart apache2" | sudo tee /etc/cron.d/apache_restart
mod_wsgi
a2dismod php8.2 mpm_prefork # Example: Disable PHP and prefork systemctl restart apache2
mpm_event
a2dismod mpm_prefork a2enmod mpm_event systemctl restart apache2
tail -n 100 /var/log/php8.2-fpm.log
/etc/php/8.2/fpm/pool.d/www.conf
pm.max_children = 10 # Reduce from default (e.g., 50) pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 4 pm.max_requests = 500 # Restart workers after 500 requests
systemctl restart php8.2-fpm apache2
MaxRequestWorkers
MaxClients
/etc/apache2/apache2.conf
/etc/apache2/mpm_prefork.conf
<IfModule mpm_prefork_module> StartServers 2 MinSpareServers 2 MaxSpareServers 4 MaxRequestWorkers 10 # Default is often 150+! Reduce to 10-20 for 2GB RAM MaxConnectionsPerChild 1000 </IfModule>
MaxRequestsPerChild
N
MaxRequestsPerChild 1000
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf sysctl -p
/etc/sysctl.conf
vm.min_free_kbytes = 65536 # Reserve 64MB for kernel
sysctl -p
apt install nginx php8.2-fpm systemctl disable apache2 systemctl enable nginx php8.2-fpm
netdata
prometheus
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
Question: Are you running any specific web apps (e.g., WordPress, Nextcloud) or custom Apache modules? This will help narrow down the root cause.
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more