[CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread Alexander Farber
Hello,

I'm using CentOS 6.2 with the stock rpm
php-5.3.3-3.el6_2.8.x86_64
and the following /etc/php.ini file:

  error_reporting = E_ALL  ~E_DEPRECATED
  display_errors = Off
  error_log = /var/log/php/php_errors.log

and that file is very useful for me because I have many custom
PHP-scripts at my site, but that file keeps growing too... :-)

So my question is for how to rotate it (esp. since it should
be owned by apache user) - what do you guys use?

Regards
Alex
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread Luigi Rosa
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Alexander Farber said the following on 05/06/12 15:57:

 So my question is for how to rotate it (esp. since it should be owned by
 apache user) - what do you guys use?

the standard logrotate config /etc/logrotate.d/httpd or a modified copy of it

since the rotation moves the old log and then reloads Apache, you don't have
to worry about the ownership issue



Ciao,
luigi

- -- 
/
+--[Luigi Rosa]--
\

First Law of Socio-Genetics: Celibacy is not hereditary.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/OEeAACgkQ3kWu7Tfl6ZR5xACdGmRGc9sSBZVRiZy1pzuTBVv/
qsEAoKR1NfYc7lYMhtIwuYEtZd+0Rlfk
=jRtF
-END PGP SIGNATURE-
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread Alexander Farber
Hello Luigi and others,

On Tue, Jun 5, 2012 at 4:04 PM, Luigi Rosa li...@luigirosa.com wrote:
 Alexander Farber said the following on 05/06/12 15:57:

 So my question is for how to rotate it (esp. since it should be owned by
 apache user) - what do you guys use?

 the standard logrotate config /etc/logrotate.d/httpd or a modified copy of it

 since the rotation moves the old log and then reloads Apache, you don't have
 to worry about the ownership issue

yes, I'm aware of that file and have modified
the docs path in it because I have several vhosts too...

Here is my current /etc/logrotate.d/httpd file:

/var/log/httpd/my_vhost_1/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/sbin/service httpd reload  /dev/null 2/dev/null || true
endscript
}

But my problem is I don't know how to do it best -
i.e. where to put the PHP log file
/var/log/php/php_errors.log
in the directives above and also how to rotate
the logs for all vhosts I have (I currently rotate just
for one - the my_vhost_1 as you can see above)

Regards
Alex
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread Alexander Farber
And also the files I rotate by the
 /etc/logrotate.d/httpd
belong to root and not Apache

# ls -al /var/log/httpd/my_vhost_1/
-rw-r--r--. 1 root root 144298773 Jun  5 16:17 access_log
-rw-r--r--. 1 root root 391503903 May 13 03:18 access_log-20120513
-rw-r--r--. 1 root root 369049605 May 20 03:35 access_log-20120520
-rw-r--r--. 1 root root 373837973 May 27 03:18 access_log-20120527
-rw-r--r--. 1 root root 381816772 Jun  3 03:32 access_log-20120603
-rw-r--r--. 1 root root  2854 Jun  5 14:01 error_log
-rw-r--r--. 1 root root  4255 May 13 00:40 error_log-20120513
-rw-r--r--. 1 root root  5580 May 19 20:17 error_log-20120520
-rw-r--r--. 1 root root  6634 May 27 00:17 error_log-20120527
-rw-r--r--. 1 root root  6014 Jun  3 02:46 error_log-20120603
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread John Doe
From: Alexander Farber alexander.far...@gmail.com

 And also the files I rotate by the
 /etc/logrotate.d/httpd
 belong to root and not Apache

Maybe check the create option in the man page...

JD
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to rotate PHP error log - since it belongs to apache

2012-06-05 Thread Andre Goree
On 06/05/2012 10:15 AM, Alexander Farber wrote:
 Hello Luigi and others,
 
 On Tue, Jun 5, 2012 at 4:04 PM, Luigi Rosa li...@luigirosa.com wrote:
 Alexander Farber said the following on 05/06/12 15:57:

 So my question is for how to rotate it (esp. since it should be owned by
 apache user) - what do you guys use?

 the standard logrotate config /etc/logrotate.d/httpd or a modified copy of it

 since the rotation moves the old log and then reloads Apache, you don't have
 to worry about the ownership issue
 
 yes, I'm aware of that file and have modified
 the docs path in it because I have several vhosts too...
 
 Here is my current /etc/logrotate.d/httpd file:
 
 /var/log/httpd/my_vhost_1/*log {
 missingok
 notifempty
 sharedscripts
 delaycompress
 postrotate
 /sbin/service httpd reload  /dev/null 2/dev/null || true
 endscript
 }
 
 But my problem is I don't know how to do it best -
 i.e. where to put the PHP log file
 /var/log/php/php_errors.log
 in the directives above and also how to rotate
 the logs for all vhosts I have (I currently rotate just
 for one - the my_vhost_1 as you can see above)
 
 Regards
 Alex
 ___
 CentOS mailing list
 CentOS@centos.org
 http://lists.centos.org/mailman/listinfo/centos


Create a different file under /etc/logrotate.d (perhaps name it
phplog, doesn't really mater though) and add the appropriate
configuration options.  I used this website to help me with the
necessary options (though the man page is more than sufficient as well):
 http://www.thegeekstuff.com/2010/07/logrotate-examples/

Here is a custom logrotate conf I created for my catalina logs:


[root@390405-web1 images]# cat /etc/logrotate.d/tomcat
/opt/apache-tomcat-5.5.34/logs/catalina.out {
 daily
 copytruncate
 delaycompress
 missingok
 postrotate
/root/bin/catlog_mv.sh
 endscript
}


If you were wanting to rotate according to the size of the file (perhaps
512MB, whatever works for you though) owned by apache, you might create
a file under /etc/logrotate.d/ containing something like the following:

/var/log/php/php_errors.log {
 size 512MB
 create 644 apache apache
 missingok
 compress
}


There's all kinds of other options you can add as well.  Read the
article I linked earlier and/or the man page, it's really pretty
trivial.  Good luck :)

-- 
Andre Goree
an...@drenet.info
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos