วันพุธที่ 17 กุมภาพันธ์ พ.ศ. 2553

Apache Mod setenvif

Some software/browser didn't follow the standard or have some bugs. I found that MSIE 6 have problem with richtext editor -javascript. Mod setenvif can be used to set special variable to correct the problem.



In file: /etc/apache2/mods-enabled/setenvif.conf
BrowserMatch "MSIE 4\.0b2;" gzip-only-text/html
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

With this line apache the user with MSIE6 will be:
-send gzip format for text/html only
-disable keepalive
-downgraded request to HTTP 1.0
-response with HTTP 1.0

To find our more directive of this mod.
http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html

There are more interesting variable that can be set.
http://httpd.apache.org/docs/2.2/env.html

วันศุกร์ที่ 12 กุมภาพันธ์ พ.ศ. 2553

Ubuntu package management & package installed for web server

Update list of package
#apt-get update

Upgrade all package in system
#apt-get upgrade

To install package
#apt-get install foo

To remove package
#apt-get remove foo
-remove configuration on the system
#apt-get --purge remove for

To upgrade all packages on the system
#apt-get dist-upgrade

apt-cache : query package list tool

To find packages whose description contain word:
#apt-cache search word

To print the detailed information of a package:
#apt-cache show package

To print the packages a given package depends on:
#apt-cache depends package

#To print detailed information of the versions available for a package and the packages
that reverse-depends on it:
apt-cache showpkg package



PHP package
php5
php5-cgi
php5-cli
php5-curl
php4-common
php5-gd
php5-imagick
php5-memcache
php5-mysql
php5-xcache
libapache2-mod-fcgid
nfs-kernel-server


Apache package
apache2
apache2-mpm-worker
apache2-utils
apache2.2-bin
apache2.2-common
libapache2-mod-fcgid


Apache Ubuntu vs Apache gentoo
add user apache with uid81 (gentoo)
#useradd -r -u 81 apache

edit /etc/apache2/envvars to run apache with user apache

Reference :
A Debian Package Primer: Part One
Aptitude :part two
Ubuntu Community Doc.

วันพฤหัสบดีที่ 11 กุมภาพันธ์ พ.ศ. 2553

Understanding apache config order in debian/ubuntu

In ubuntu, i've found a lot of config file for apache. To identify the problem, you need to know which config loading sequence which might overwrite another one.

/etc/apache2

1) apache2.conf - define #process, timeout etc...
2) mods-enabled/*.conf - module configuration
3) httpd.conf (user configuration)
4) ports.conf - port listening
5) conf.d/*- generic snippet statement - charset localized-error-pages, security
6) sites-enable/* -all vhost

xcache opcode/optimizer for php tunning

Installing xcache can help php-apache app responding faster.

1) installing xcache
gentoo :
#emerge cache
ubuntu/debian
#apt-get install php5-xcache

after installing you will see path for xcache admin
2) set xcache config and admin password
#echo -n "yourpassword" | md5sum
edit xcache.ini this line :
xcache.admin.pass="" (from previous command)
http://xcache.lighttpd.net/wiki/XcacheIni

3) point apache to xcache admin path

4) browse xcache admin with browser

use this admin page to see what variable need to be adjusted.

I'll point some importtatn config

xcache.size
- set just fit, not too low or too high. see OOM(out of memory column) from admin page. If there are lots of OOM, please consider increasing.

xcache.count
- set to number of your cpu : cat /proc/cpuinfo | grep -c processor

xcache.slots
- the more slot, the faster PHP code accessing


More reading here :

วันอังคารที่ 9 กุมภาพันธ์ พ.ศ. 2553

rrdtool tune rra file

Using SNMP and cacti, you need to adjust rrd file manually for displaying graph correctly.

/cacti/rra
show file info to see the limitation of value
#rrdtool info filename.rrd

tunning it
#rrdtool tune filename.rrd --maximum cpu_user:800

วันจันทร์ที่ 8 กุมภาพันธ์ พ.ศ. 2553

gentoo SNMP

Installing SNMP in gentoo for system monitoring.


#emerge net-snmp

edit /etc/snmp/snmpd.conf add the following
com2sec Mybox localhost public
com2sec cacti 192.168.1.0/24 public

group RWGroup v2c Mybox
group ROGroup v1 cacti
group ROGroup v2c cacti

view all included .1 80
view system included system fe

access ROGroup "" any noauth exact all none none
access RWGroup "" v2c noauth exact all all all

#rc-update add snmpd default