Notes on PHP handlers

Comparison Graph

Low CPU usage
Low Memory consumption
Runs PHP as site owner instead of Apache

only w/ suEXEC
Good security

Reference from:


PHP-FPM (reference)

PHP-FPM = all fcgid + advantage of a shared APC cache for all processes.

mod_php vs FastCGI (reference)


when use mod_php, apache use less memory then FastCGI process
However, apache use less memory when using FastCGI which apache can process more static file requests

Apache pre-fork <= higher when many static files requested
fcgi 15 processes * (40 MB – 21 MB shared) + 21 MB shared + (20 Apache procs * 6 MB [120MB]) = 426 MB

Apache threaded MPM-Worker
fcgi 15 processes * (40 MB – 21 MB shared) + 21 MB shared + (10 Apache procs * 25 MB [250MB]) = 556 MB

mod_php 26 processes * (26 MB – 13 MB shared) + 13 MB shared = 351 MB

2. the number of MySQL threads went down dramatically, because only PHP processes will connect to it, and not every Apache process. Reduced from 15 connections to 1-2 connections

3. the number of network connections inside the server reduced from 1400 to around 200


I have confused for many time about these three terms, STARTTLS vs SSL vs TLS.

Therefore, I did some research and summarize them in short.

  • STARTTLS is a way to use an existing insecure connection and upgrade it to be secured through TLS or SSL.
  • SSL/TLS is a way to form secure connection natively.
  • TLS is the successor to SSL. Their history is SSLv2 -> SSLv3 -> TLSv1.0 -> TLSv1.1 -> TLSv1.2
  • SMTP SSL/TLS encrypted over port 465
  • SMTP with STARTTLS upgrading over port 587 (ISP can block port 25 to prevent most of the spammer in ISP network)

Thunderbird – Outlook-style reply headers

By default, Thunderbird shows only the Date and sender’s name when you reply a mail.
The information is not enough when you would like to trace e-mail conversion later on.

Therefore, I introduce you to use this 3rd party plug-in called “Change quote and reply format” created by Kaosmos

The reply header after using the plug-in:

—- Original message —–
Subject: something
Date: 01/01/2005


Use MySQL ON DUPLICATE KEY UPDATE to update data in insert SQL statement

If you get a SQL dump of a database table and want to update part of the data into existing table, you can use the following SQL statement to achieve it.

INSERT INTO `t_products` (`productid`, `prodname_en`, `proddesc_en`) VALUES(222, ‘This is the product name’, ‘This is the product description’)  ON DUPLICATE KEY UPDATE some_column1=VALUES(prodname_en), some_column2=VALUES(proddesc_en);


Test a e-mail by Spamassassin manually and get spam report

If you want to test a e-mail or test whether the spamassassin rule is working or not, you can use the following command

spamassassin -t  /the_message.txt

Then you will get something like this

Received: from localhost by
with SpamAssassin (version 3.3.2);
Wed, 22 Aug 2012 21:58:21 +0800
From: =?utf-8?B?5om25reR5rK7?= <>


Content analysis details: (10.3 points, 5.0 required)

pts rule name description
—- ———————- ————————————————–
1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in
[Blocked – see <>]
4.0 RCVD_IN_CASA_CBLLESS RBL: IP has be listed in China Anti-Spam
Alliance CBL-,
[ listed in]
2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL
[ listed in]
[ listed in]
0.7 RCVD_IN_XBL RBL: Received via a relay in Spamhaus XBL
[ listed in]
0.0 HTML_MESSAGE BODY: HTML included in message


Exim: update the recipient of a e-mail message in the query

1. check the exim mail query by specific the sender or recipient

exiqgrep -f


exiqgrep -r


2. Get the message_id from above and add a new recipient to the message

exim -Mar message_id email@domain.dom

3. Exim doesn’t support delete a recipient, however, we can mark the wrong recipient as delivered

exim -Mmd message_id email@domain.dom

4. Deliver the message

exim -M message_id