exim: Check current PHP Script Spam process



This post is very useful for those System Administrator or System Engineer who wish to monitor over hundred of servers which could get the spamming PHP script immediately from your server.

The following example was written based on cPanel exim4 and you may stored them in a .sh file.

Continue reading exim: Check current PHP Script Spam process

cPanel: Configuring PHP and suEXEC from the Command Line

With cPanel, you do not need to recompile the whole easyapache to get your PHP or suEXEC to be run, you may easily get the PHP work with the rebuild_phpconf script to update the php.conf file.

To see a list of all options and arguments for the script, you may type the following from the command line,
/usr/local/cpanel/bin/rebuild_phpconf –help

If you wish to use PHP 5, CGI handler and enable suEXEC, you might type as,
/usr/local/cpanel/bin/rebuild_phpconf 5 cgi cgi 1

If you wish to use PHP 5, suPHP and enable suEXEC, you might type as
/usr/local/cpanel/bin/rebuild_phpconf 5 suphp suphp 1

The available PHP handler is as cgi, dso, none, fcgi and suphp.

Enable Zlib to get faster site browsing

Everyone want a lightening fast website speed instead of turtle speed.

To get faster speed of your website, you may enable zlib or gzip. In this session, you will learn how to enable zlib from your PHP script.

To enable zlib, head to your php.ini file and change the value as below.

If your host do not support for php.ini file, you may easily add this to your php script.
ini_set(’zlib.output_compression’, ‘On’);
ini_set(’zlib.output_compression_level’, ‘1′);

MySQL: Load Data Infile or Outfile

For many cases, you might want to load your data out from the database to a text file or dump the database through the SQL query with a .sql file without a control panel such as phpmyadmin, etc. You may actually done it through the MySQL console query engine.

In this article, Mick Genie will guide you on Load Data Infile and Outfile from MySQL databases query.

Basically, you will need to understand what is infile and what is outfile, to differentiate it, you might refer to the detail as below.
infile: when you using infile, that meant you are inserting data to the database and it is the same when you are using < symbol from the MySQL console.
outfile: If you understand infile, then you shall understand outfile is use to grep the data from the database and store to the text.

Below is the sample script with infile could be used from the PHP script.

$tableName  = ‘mickgenie’;
$query = “LOAD DATA INFILE ‘mickgenie.sql’ INTO TABLE $tableName”;
$result = mysql_query($query);

Below will be the outfile sample from the MySQL query.


Create your maintenance page with PHP

With maintenance page created, it is very helpful for a web programmer to perform the maintenance and other task if it is needed.

Actually it is very easy to create maintenance page for a PHP script, all you need is create a simple maintenance page with image or meaningful word with maintenance.html and php script with maintenance.php.

I will not going to teach you to create the maintenance.html where you may just put it as “Domain.com is under maintenance” or whatever.

Today, I will guide you the script of the maintenance function in maintenance.php.

function maintenance($mode = FALSE){
header(“Location: http://mickgenie.com/maintenance.php”);
header(“Location: http://mickgenie.com/”);


Go to your index.php or any other index handler page, add this to the line just after the PHP open tag.

Then, if you wish to enter maintenance mode, just add the following line after the require_once line.

Jailed Shell memory issue

If you are using Secure Shell (SSH), you might get these error when you running your php script.

PHP Fatal error:  Out of memory (allocated 20447232) (tried to allocate 4096 bytes) in email.php

If you are the programmer or system administrator, you might tried to increase the memory_limit from the php.ini or using ini_set to increase the memory_limit but you will find out no matter how much memory_limit you set will not solve the problem.

The reason of the error occurs is not because of the PHP memory_limit usage of your script, but it is because the jailed shell limitation.

With cPanel jailed shell, the problem could caused by the forkbomb setting of your cPanel limited the PHP memory.

You may easily get this fix by modify the file as detail below where you should change the user to the cPanel user of your account.

Search for,
if [ “$LIMITUSER” != “root” ]; then

Then modify the ulimit “-m 200000” to “-m unlimited” and save it.

Calculate PHP Load time

Have you ever load a page with your Broadband just like using a Dial Up connection? Sometimes, it is not because of the ISP connection problem but it’s just because the scripting that not fully optimized.

If you design PHP script, it’s good practice to benchmark your pages to see the if you could optimize the pages.

The following script let you understand how fast your script loaded.

Put the following script to the most top of your PHP script just after the php tag.

$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$loadstart = $m_time;

Then place this script to the bottom of the script to calculate the time.

$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$loadend = $m_time;
$loadtotal = ($loadend - $loadstart);
echo "<small><em>Generated page in ". round($loadtotal,3) ." seconds</em></small>";