Skip to content

Instantly share code, notes, and snippets.

@joelstein
Last active March 31, 2017 20:40
Show Gist options
  • Save joelstein/e2528d32747c7f5b8ce5 to your computer and use it in GitHub Desktop.
Save joelstein/e2528d32747c7f5b8ce5 to your computer and use it in GitHub Desktop.
Apache and logrotate
# First do this, then choose from one of the options below.
sudo nano /etc/logrotate.d/apache2
# Apache 2.4, Ubuntu 14.04.2 LTS
/var/www/*/log/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
# Apache 2.2, Ubuntu 10.04.4 LTS
/srv/www/*/logs/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 reload > /dev/null
fi
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment