9
Oct

apache MPM worker

   Posted by: admin   in Mẹo vặt của hiếu râu



rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
cd /tmp/
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

vim /etc/httpd/conf.d/fastcgi.conf

FastCgiWrapper Off

<IfModule mod_fastcgi.c>
    AddHandler php5-fcgi .php
    Action php5-fcgi /php5-fcgi
    Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
    DirectoryIndex index.php
    FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
</IfModule>

mkdir -p /usr/lib/cgi-bin

vim /etc/php-fpm.d/www.conf 

listen = /var/run/php5-fpm.sock
beware of sock permission ( nobody 666 )
vi /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker

Msmtp,          P=[IPC], F=mDFMuX, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,

T=DNS/RFC822/SMTP,

A=TCP $h

Mesmtp,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,

T=DNS/RFC822/SMTP,

A=TCP $h 587

Msmtp8,         P=[IPC], F=mDFMuX8, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,

T=DNS/RFC822/SMTP,

A=TCP $h

Mdsmtp,         P=[IPC], F=mDFMuXa%, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,

T=DNS/RFC822/SMTP,

A=TCP $h

Mrelay,         P=[IPC], F=mDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP, E=\r\n, L=2040,

T=DNS/RFC822/SMTP,

A=TCP $h 3535

24
Sep

Sogo webmail

   Posted by: admin   in Mẹo vặt của hiếu râu

http://www.iredmail.org/docs/sogo-centos-6-mysql.html

16
Sep

mysql store procedure/function

   Posted by: admin   in Mẹo vặt của hiếu râu


http://www.mysqltutorial.org/mysql-stored-function/


CREATE DEFINER=`hieunt`@`localhost` FUNCTION `get_range_counter`(`p_idRule` INT, `p_rType` VARCHAR(50))
RETURNS int(11)
LANGUAGE SQL
NOT DETERMINISTIC
READS SQL DATA
SQL SECURITY DEFINER
COMMENT ''
BEGIN

DECLARE ret INT;

select sum(b.rE-b.rB+1) as DIP INTO ret
from tbl_rule_detail b
where b.rType=p_rType and b.idRule= p_idRule;

if p_rType='SP' or p_rType='DP' then
if ret>=65536 then set ret=0; end if;
else
if ret>=2147483647 then set ret=0; end if;
end if;

return (ret);

END

//—————–

select a.id,b.code_ticket ,a.SourceVlan,a.SourceIP,a.SourcePort,a.DesVLan,a.DesIP,a.DesPort,a.Protocol,
get_range_counter(a.id,'SIP') as SIP,
get_range_counter(a.id,'SP') as SP,
get_range_counter(a.id,'DIP') as DIP,
get_range_counter(a.id,'DP') as DP
from tbl_rule_request a, tbl_tickets b
where TO_DAYS(a.LastSeen)>TO_DAYS(NOW())-2 and a.idTicket=b.id
having (SIP>20)or (DIP>20) or SP>10 or DP>10
order by (DP+SP+DIP+SIP) DESC
19
Jun

SSL telnet

   Posted by: admin   in Mẹo vặt của hiếu râu

openssl s_client -connect example.com:443 -ssl3
19
Jun

sendmail authinfo

   Posted by: admin   in Mẹo vặt của hiếu râu

FEATURE(`smrsh’, `/usr/sbin/smrsh’)dnl
FEATURE(`authinfo’, `hash -o /etc/mail/authinfo.db’)dnl
FEATURE(`mailertable’, `hash -o /etc/mail/mailertable.db’)dnl
FEATURE(`virtusertable’, `hash -o /etc/mail/virtusertable.db’)dnl

/etc/mail/authinfo

AuthInfo:[1.1.1.1] “U:yourusername” “P:yourpassword” “M:LOGIN PLAIN”

/etc/mail/mailertable

testmail.com    esmtp:[1.1.1.1]

#make

O LogLevel=15

sendmail restart

23
Jan

mod_reqtimeout.so

   Posted by: admin   in Mẹo vặt của hiếu râu

Apache slowris attack

LoadModule reqtimeout_module modules/mod_reqtimeout.so

RequestReadTimeout header=10-30,MinRate=500 body=10,MinRate=2000

13
Jan

xen virt-manager tap2

   Posted by: admin   in Mẹo vặt của hiếu râu

http://wiki.centos.org/HowTos/Xen/Xen4QuickStart

http://wiki.centos.org/HowTos/Xen/Xen4QuickStart/Xen4Libvirt

vi /usr/lib/python2.6/site-packages/virtinst/VirtualDisk.py

replace “tap” ==> “tap2″

python -m compileall /usr/lib/python2.6/site-packages/virtinst/

27
Oct

Phonegap - Hellow world

   Posted by: admin   in Mẹo vặt của hiếu râu

download android sdk, adt, unzip vao c:\adt

$ android create avd –name avd19 –target android-19

download nodejs http://nodejs.org/download/ , chon windows bin 32 hoac 64 bits, copy vao c:\adt\node.exe

download npm, http://nodejs.org/dist/npm/ , unzip vao c:\adt\

download http://ant.apache.org/ , unzip vao c:\adt\ant , set PATH=c:\adt\ant\bin

C:\> npm install -g phonegap

$ phonegap create my-app
$ cd my-app
$ phonegap install android
$ phonegap run android

$ plugman install –platform android –project “c:\adt\my-app\platforms\android” –plugin org.apache.cordova.device

$ phonegap local plugin add org.apache.cordova.device
DEBUG tool
$ npm -g install weinre
$ weinre --boundHost yourIP
open web http://yourIP:8080/client
put this line to www/index.html
<script src="http://yourIP:8080/target/target-script-min.js"></script>

cd /path/to/dir
find . -type f -name ‘*.html’ -exec grep -l “abcxyz” {} +

find . -type f -name ‘*.html’ -exec grep “abcxyz” {} +

for i in `ls /var/spool/mqueue/qf*`; do  grep ‘abcxyz’ $i && rm -f $i; done