XP-rience

Something that I'd like to share with you!

Showing posts with label xampp. Show all posts

Tuesday, July 27, 2010

Using rotatelogs to manage Logs in Apache (xampp)

No comments :
While performing a routine XAMPP (under Linux) healthy check, I've found out some log files had grown up to about 8GB. This might cause the system to slow down. Searching for a solution from the net lead me to this, rotatelogs. To use this rotatelogs it needs to be piped in the XAMPP httpd.conf which is located at /opt/lampp/etc/httpd.conf. So I comment out the 2 original lines and add 2 lines with rotatelogs piped to them like below;

#ErrorLog logs/error_log
ErrorLog "|bin/rotatelogs logs/error_log 5M"
...
#CustomLog logs/access_log common
CustomLog "|bin/rotatelogs logs/access_log 5M" common

Next is to restart the XAMPP by doing ./lampp restart (XAMPP for Linux). Unfortunately it failed and when I observed the error.log it shows;

piped log program 'bin/rotatelogs... failed unexpectedly

Maybe the path is wrong. Next try is to use full path by replace those rotatelogs piped lines with below;

#ErrorLog logs/error_log
ErrorLog "|/opt/lampp/bin/rotatelogs /opt/lampp/logs/error_log 5M"
...
#CustomLog logs/access_log common
CustomLog "|/opt/lampp/bin/rotatelogs /opt/lampp/logs/access_log 5M" common

Finally it works. No error in error_log found. New log file will be created whenever it reach 5MB size. Whenever it switch to the new log file, a unixtime will be appended to the log file name like below;

-rw-r--r-- 1 root root 22713 Jul 27 10:10 access_log.1280196529
-rw-r--r-- 1 root root 4989 Jul 27 10:21 access_log.1280197231
-rw-r--r-- 1 root root 725 Jul 27 10:20 error_log.1280197229

Log file size above is not 5MB yet but when I restart XAMPP, new log file is created. But I'm thinking, what if I don't want to keep all logs, just rotate them weekly. So I try this;

#ErrorLog logs/error_log
ErrorLog "|/opt/lampp/bin/rotatelogs /opt/lampp/logs/error_log.%a 86400"
...
#CustomLog logs/access_log common
CustomLog "|/opt/lampp/bin/rotatelogs /opt/lampp/logs/access_log.%a 86400" common

The new log file name now looks something like below.

-rw-r--r-- 1 root root 625 Jul 27 12:04 error_log.Tue
-rw-r--r-- 1 root root 1941 Jul 27 12:04 access_log.Tue

They will rotate in 24 hours (86400 secs) with a 3-character weekday name appended to them. I assume they will rotate and replace just like I plan in 1 week time, I hope so. :-)

Wednesday, August 13, 2008

Enabling OCI8 for XAMPP under Linux

1 comment :
Following instruction from

http://www.apachefriends.org/f/viewtopic.php?t=27559&sid=96d42fb6867daf5d8932fdacf4232d58
,
here are my output.

My case is similar to this problem. The only different is, I have libclntsh.so.9.* which is older than the expected version. BTW, my OS is SLES 9.3. First thing to do is to download Oracle Instant Client version 10 to match the expected version from;

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html


It is recommended to download .gz version than .rpm version since the .gz version is quite easy to be extracted. My case, I accidentally downloaded the .rpm version. So to extract it need special rpm2cpio command as below.

normuser@MYSERVER:~/OC> ls -al
total 32048
drwxr-xr-x 2 normuser normgroup 112 2008-08-12 13:03 ./
drwxr-xr-x 13 normuser normgroup 784 2008-08-12 13:03 ../
-rw-r--r-- 1 normuser normgroup 32782200 2008-08-12 12:55 oracle-instantclient-basic-10.2.0.4-1.i386.rpm

normuser@MYSERVER:~/OC> rpm2cpio oracle-instantclient-basic-10.2.0.4-1.i386.rpm | cpio -idv
./usr/lib/oracle/10.2.0.4/client/bin/genezi
./usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so.10.1
./usr/lib/oracle/10.2.0.4/client/lib/libnnz10.so
./usr/lib/oracle/10.2.0.4/client/lib/libocci.so.10.1
./usr/lib/oracle/10.2.0.4/client/lib/libociei.so
./usr/lib/oracle/10.2.0.4/client/lib/libocijdbc10.so
./usr/lib/oracle/10.2.0.4/client/lib/ojdbc14.jar

Now, copy all .so files into xampp lib directory named /opt/lampp/lib/.

MYSERVER:/apps/home/normuser/OC/usr/lib/oracle/10.2.0.4/client/lib # cp * /opt/lampp/lib/

Next is to issue the lampp oci8 command by telling the program that the expected libs are at /opt/lampp/lib/ as root since xampp is under root.

MYSERVER:/opt/lampp # ./lampp oci8
Please enter the path to your Oracle or Instant Client installation:
[/opt/oracle] /opt/lampp/lib
installing symlink...
patching php.ini...
OCI8 add-on activation likely successful.
XAMPP: Stopping Apache with SSL...
XAMPP: Starting Apache with SSL (and PHP5)...

Now you can test your connection with some PHP example code from
http://www.php.net/oci8