Archive | March, 2009

Activate GZIP compression in Apache

Create a file at /etc/httpd/conf.d/deflate.conf with the following contents: SetOutputFilter DEFLATE # Don’t compress picture files SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \ no-gzip dont-vary # Don’t compress compressed files SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary # Don’t compress pdf’s SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with [...]

Create a file at /etc/httpd/conf.d/deflate.conf with the following contents:

SetOutputFilter DEFLATE

# Don't compress picture files
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \ no-gzip dont-vary

# Don't compress compressed files
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary

# Don't compress pdf's
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
View Comments Continue Reading →

Apache MaxClients

Determine the “max process size”: ps -ylChttpd –sort=rss |less will give output like: S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD S 48 21481 20626 0 75 0 9028 75762 semtim ? 00:00:01 httpd S 48 21487 20626 0 75 0 9040 75762 semtim ? 00:00:01 httpd S 48 21482 [...]

Determine the “max process size”:

ps -ylChttpd --sort=rss |less

will give output like:

S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S    48 21481 20626  0  75   0  9028 75762 semtim ?        00:00:01 httpd
S    48 21487 20626  0  75   0  9040 75762 semtim ?        00:00:01 httpd
S    48 21482 20626  0  75   0  9064 75762 semtim ?        00:00:01 httpd
S    48 21486 20626  0  75   0  9088 75762 semtim ?        00:00:01 httpd
S    48 21485 20626  0  75   0  9096 75762 semtim ?        00:00:00 httpd
S    48 21488 20626  0  75   0  9104 75762 semtim ?        00:00:01 httpd
S    48 21017 20626  0  75   0  9116 75762 semtim ?        00:00:02 httpd
S    48 21019 20626  0  75   0  9168 75762 semtim ?        00:00:01 httpd
S    48 20645 20626  0  75   0  9188 75762 semtim ?        00:00:03 httpd
S    48 20703 20626  0  75   0  9304 75795 semtim ?        00:00:02 httpd
S    48 20628 20626  0  75   0  9324 75795 semtim ?        00:00:02 httpd
S    48 20629 20626  0  75   0  9376 75829 -      ?        00:00:02 httpd
S    48 20630 20626  0  75   0  9408 75829 semtim ?        00:00:01 httpd
S    48 20633 20626  0  75   0  9412 75829 semtim ?        00:00:02 httpd
S    48 20634 20626  0  75   0  9432 75829 -      ?        00:00:02 httpd
S    48 20631 20626  0  75   0  9448 75829 semtim ?        00:00:01 httpd
S    48 20632 20626  0  75   0  9692 75800 semtim ?        00:00:02 httpd
S    48 20704 20626  0  75   0  9788 75795 semtim ?        00:00:02 httpd
S    48 20635 20626  0  75   0 10016 75964 semtim ?        00:00:02 httpd
S    48 20705 20626  0  75   0 10040 75964 semtim ?        00:00:03 httpd
S     0 20626     1  0  78   0 14768 75729 -      ?        00:00:00 httpd

Use the largest value in the RSS column. In this case 14768. The number is in KB of memory.

Determine MaxClients by dividing the available memory by the max process size. Keep in mind that MySQL and other applications may need some memory.

Here’s a one liner to get max per process usage:

ps -ylChttpd --sort=rss | cut -f 16 -d " " | grep -v RSS | sort -n -r | head -1
View Comments Continue Reading →

Here Doc

A “here document” is a method for specifying a multi-line string literal in many programming languages. Here are some examples: Perl print <<”END”; MULTIPLE LINES OF TEXT HERE END PHP echo <<<EOF MULTIPLE LINES OF TEXT HERE EOF; Bash cat <<EOF MULTIPLE LINES OF TEXT HERE EOF Bookmark on Delicious Digg this post Recommend on [...]

A “here document” is a method for specifying a multi-line string literal in many programming languages. Here are some examples:

Perl

print <<"END";

MULTIPLE LINES OF TEXT HERE

END

PHP

echo <<<EOF

MULTIPLE LINES OF TEXT HERE

EOF;

Bash

cat <<EOF

MULTIPLE LINES OF TEXT HERE

EOF
View Comments Continue Reading →

PHP Mailer : Swift Mailer

Every time I need a PHP class to handle sending email I turn to Swift Mailer at: http://swiftmailer.org. It’s feature rich and easy to use. Only downside is it doesn’t work for PHP4. Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments [...]

Every time I need a PHP class to handle sending email I turn to Swift Mailer at:

http://swiftmailer.org.

It’s feature rich and easy to use.

Only downside is it doesn’t work for PHP4.

View Comments Continue Reading →

Zimbra – Set MTA Trusted Networks From Command Line

To view trusted networks as the zimbra user: /opt/zimbra/bin/zmprov gs {servername} zimbraMtaMyNetworks To set trusted networks as the zimbra user do: /opt/zimbra/bin/zmprov ms {servername} zimbraMtaMyNetworks {space delimited list of address and/or cidr ranges} Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments [...]

To view trusted networks as the zimbra user:

/opt/zimbra/bin/zmprov gs {servername} zimbraMtaMyNetworks

To set trusted networks as the zimbra user do:

/opt/zimbra/bin/zmprov ms {servername} zimbraMtaMyNetworks {space delimited list of address and/or cidr ranges}
View Comments Continue Reading →