Posts

varnish web accelerator

Varnish web application accelerator homepage: https://www.varnish-cache.org Install the Varnish YUM Repository # rpm -Uvh http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm Install Varnish web accelerator # yum install varnish Enable Varnish web accelerator at startup # chkconfig varnish on Basic default.vcl # vi /etc/varnish/default.vcl 1 2 3 4 5 6 7 8 9 10 # This is a basic VCL configuration file for varnish. See the vcl(7) # man page for details on VCL syntax and semantics. # # Default backend definition. Set this to point to your content # server. # backend default { .host = "127.0.0.1"; .port = "80"; } Start Varnish web accelerator # service varnish start You will now have a basic Varnish web accelerator running on port 8080 Top 5 Varnish commands varnishstat Provides all the info you need to spot cache misses and errors. varnishhist Provides a histogram view of cache hits/m...

Centos 4 and Dovecot 1

 Centos 4 and dovecot 1 fail2ban from: http://www.webstershome.co.uk/content/fail2ban-block-unwanted-attacks Create the filter file "/etc/fail2ban/filter.d/dovecot-pop3imap.conf" and add [Definition] failregex = (?: dovecot: pop3-login|imap-login): (?:Authentication failure|Aborted login \(auth failed|Aborted login).*rip=(<HOST>),.* ignoreregex = note: the failregex may need changing to suit your system. now add the following to "/etc/fail2ban/jail.conf" [dovecot-pop3imap] enabled = true filter = dovecot-pop3imap action = iptables-multiport[name=dovecot-pop3imap, port="110,143,995,993,25,465,587"] sendmail-whois[name=dovecot-pop3imap, dest=root, sender=fail2ban@server.com] logpath = /var/log/maillog maxretry = 5 findtime = 600 bantime = 3600

Recursive searching via grep and sed

echo "Enter string to be placed" read NEWSTRING echo "===================================" echo "string to be replaced is $OLDSTRING" echo "string to be placed is $NEWSTRING  " echo "===================================" oldstr=$OLDSTRING #string to be replaced newstr=$NEWSTRING #new string to be placed echo "Enter folder path where we will find the string" read FOLDERPATH ### grep oldstring and output it in grep_output.txt    STEP1 grep -rl $oldstr $FOLDERPATH > grep_output.txt ### since there might be spaces or special characters on filenames, use sed to enclose them with quote and output in  sed_output.txt  STEP2 #for i in `cat grep_output.txt` #do sed -e "s/'/'\\\\''/g;s/\(.*\)/'\1'/" grep_output.txt  > sed_output.txt #done for i in `cat grep_output.txt` do sed -i "s/$oldstr/$newstr/g" $i > sed_output_new_old_string.txt done ## NOTE ## # 2013 latest ## STEP 2 Seems not wo...

Bash create notification using du -h --max-depth

Created this simple script to email disk space usage. #!/bin/bash ## Email directory list if over quota BASE2=/home/vmail/mazaredo.com ## Check whole directory summary BASE=/home/vmail #50GB THRESHOLD=52428800 # out=$(du -s $BASE | cut -f1) # if [ $out -gt $THRESHOLD ] then  echo $out  du -h --max-depth=1 $BASE2 | mail -s "DISK USAGE EXCEEDED" postmaster@example.com else  echo "quota not reached" fi

install suhosin patch on centos

credit to : http://www.cyberciti.biz/faq/centos-rhel-6-install-suhosin-php-advanced-protection-system/ # yum install php-suhosin edit config /etc/php.d/suhosin.ini

installing ioncube on 2.6.32-358.18.1.el6.i686 #1 SMP Wed Aug 28 14:27:42 UTC 2013 i686 i686 i386 GNU/Linux

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.zip unzip the file. create a directory on /usr/local/ioncube copy all extracted files on /usr/local/ioncube edit php.ini and insert this line zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.3.so restart apache and check if loaded. php -v if an error occurs try 5.4, 5.2, 5.1 and so on creadit to : http://blog.hostonnet.com/installing-ioncube-loader-on-centos

Mysql Fix Duplicate Entry | Mysql Master Slave

 mysql> show slave status\G Last_SQL_Error: Error 'Duplicate entry 'example@google.com' for key 'PRIMARY'' on query. STEP: Delete the entry on the slave (make sure you check if you need the data copy it! ) mysql> slave stop; mysql> SET GLOBAL sql_slave_skip_counter = 1; mysql> slave start; Insert the data on your master and it should replicate now on the slave.