I enabled the error_log = /var/log/php5-fpm.log
under /etc/php5/fpm/php-fpm.conf
on my ubuntu 12.04 running nginx and php5-fpm.
But I noticed that php5-fpm.log does not logrotate. I tried to understand some of the configuration I found from the internet but I'm reluctant to test it on my production server.
Here are some of the config that I found:
/var/log/php5-fpm.log {
rotate 12
weekly
missingok
notifempty
compress
delaycompress
postrotate
invoke-rc.d php5-fpm reopen-logs > /dev/null
endscript
}
This is the link of the config. As I understand, all I need is to create a file called php5-fpm
under /etc/logrotate.d/
, so it will look like /etc/logrotate.d/php5-fpm
and with the above code.
I also found another sample from this link with the following code:
/var/log/php5-fpm.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
[ ! -f /var/run/php5-fpm.pid ] || kill -USR1 `cat /var/run/php5-fpm.pid`
endscript
}
Since I'm new to logrotate configuration, I want to make sure that what I will do is correct.
So, which of the two configuration is correct? The first one or the second one? And is it correct that I will create a file only at /etc/logrotate.d/php5-fpm
and put the code in there?
Sorry if this is a newbie question, I just can't find the complete explanation on how to do this.