Why you MUST optimise your images for the web
1/5/2012 external link
When you upload image to be viewed over the internet through a web browser then you have to make sure that they are “optimised” correctly for the best user experience.
For example, most digital cameras these days will take a high resolution image which is nice to look at locally on your pc screen, but these usually come at hefty file sizes and dimensions and is impractical for viewing on a web site due to the various speeds of users connections and screen resolutions.
The result of uploading high resolution images to a web page will result in the following problems and knock on effects:
depending on the users internet connection speed, the user will need to wait whilst each image downloads before they can view them
depending on the users screen size, a high resolution image may not render correctly in the browser and may overcrowd the users screen space
if your page takes long to load due to downloading many large files, google will consider this to be a slow site and will not rank you.
if your page takes long to load, ie more than a few seconds, then the user may decide to look at another site which loads faster.
The first two items result in poor user experience and the third and fourth are knock on effects because it will result in bad rankings for your site and loss of visitors.
The goal is to make sure that your images download fast and are a decent enough quality for the end user to view. As long as you optimise your images for that in mind, then the end user experience is higher than that of a site where it takes a long time for pages to load and for images to appear slowly.
So, What is a Good Size for Images?
If the images are photos, then the most flexible format is .jpeg (or .jpg). If you resize jpeg images to 550 pixels wide, disregard the height (although I dont recommend uploading images that have a height higher than 450 pixels high), usually 72 dpi images will result in app. 100kb in size. It is possible to optimise 550 pixel wide and 450 pixel height images to between 50kb – 75kb with the right software, but most resizing software can optimise images to a suitable level.
Perfect formula is: 550 pixel wide jpg in 72 dpi with max file size of between 50kb to 100kb.
This will provide a decent quality of photo viewing and optimal download of images.
What Software can i use to resize my images?
The options are vast so I am going to give you a couple of examples.
For PC – Light Image Resizer
For Mac – Pixillion Image Converter
Always keep in mind that even though you might have access to the fastest broadband internet with lightening download speeds, there are still many people that dont, there are many people still on dialup or slow 3g connections not to mention you can get penalised by search engines for having a slow web site.
Try and optimise images when and where you can.
Set up WordPress Database Connection for Dev Server and Live Server
23/4/2012 external link
If you are developing wordpress sites then more than likely you will be setting up a local dev version using something like MAMP PRO and then staging the development on your live production server at your web host.
By far the most easiest way I have found to accomplish auto switching between dev connection and live connection is to do the following.
make two copies of your wp-config.php
rename one of them wp-config-live.php
rename the other file wp-config-dev.php
open the original wp-config.php file and delete everything and drop in the following code
All you have to do then is edit the dev server name in wp-config.php, then just update the test and live config files and you are done.
Job Done! Now you have two separate config files for each server you are running.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?
//this file has been created so that we can use the same files on a local test server and live server
//craigedmonds.com 23/4/2012
//define your url for your test server
$dev_server = 'localhost.yourdomain.com';
//get relevant config file based on the host
if ( $_SERVER['HTTP_HOST'] == $dev_server ) {
include "wp-config-dev.php";
} else {
include "wp-config-live.php";
}
?>
How to backup your cpanel account on a shared server
11/4/2012 external link
I love cpanel. Its easy to use, cheap to run, stable and reliable. However given the nature of the internet and that there is always som crim out there who wants to steal your data or just plain mess with you, you have to make sure that you have a backup of your data.
Most hosts will make a weekly or monthly backup of your cpanel data (if they dont then MOVE HOST!!) however taking your own periodical backup can do no harm.
Just make sure you check with your host first to see if they allow you to take regular backups using this method and dont do hourly backups, you will eat through your bandwidth limit in no time.
Below (FIG 1) is some script I am using for a few of my clients and after some tweaking, it works great. It creates a FULL cpanel backup for your account and sends it to a remote ftp server so in the event something happens to your site, then you can transfer the backup and do a full cpanel restore.
Just do the following:
login to cpanel and go to file manager
once you are in file manager, create a new file ABOVE the /www/ folder
call the file something like “my-daily-cpanel-backup.php
copy and paste the code from FIG 1 into that file
edit your cpanel settings and ftp setting and save
Now you need to set a cron job so that it calls the file up and make the backup.
go back to cpanel home and look for the cron button
add a new cron job as in FIG 2 and FIG 3 below.
FIG 1
Copy this code into the file you made ABOVE the /www/ directory.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
// This script contains passwords. KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/)
// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********
// Info required for cPanel access
$cpuser = "xxx"; // Username used to login to CPanel
$cppass = "xxx"; // Password used to login to CPanel
$domain = "xxx"; // Domain name where CPanel is run
$skin = "x3"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme
// Info required for FTP host
$ftpuser = "xxx"; // Username for FTP account
$ftppass = "xxx"; // Password for FTP account
$ftphost = "xxx"; // Full hostname or IP address for FTP host
$ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)
$ftpport = "21"; // Port (default = 21)
$rdir = "/"; // Remote dir (defaut = / )
// Notification information
$notifyemail = "you@youremail.com"; // Email address to send results
// Secure or non-secure mode
$secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
// Set to 1 to have web page result appear in your cron log
$debug = 1;
// *********** NO CONFIGURATION NEEDED BELOW THIS LINE *********
if ($secure) {
$url = "ssl://".$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}
$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection... Bailing out!\n"; exit; }
// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);
$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$rdir&submit=Generate Backup";
// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");
// Grab response even if we don't do anything with it.
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}
fclose($socket);
?>
FIG 2:
Create a cron job inside cpanel.
FIG 3:
The following variations of cron job can be used on various servers. Just drop this into the command section of your cron job making sure you put the right path to the file.
1
php -q /home/your_cpanel_username/my-daily-cpanel-backup.php
Amazon S3 policy to give ftp access to a bucket to a user
8/4/2012 external link
I use Transit FTP to manage the contents of my buckets. Its a really nice and fast way to manage files and works exactly like FTP. If you are a windows user then you can also use something like Cloudberry Explorer Pro which is probably one of the best Amazon S3 tool, very advanced tool though!
The Amazon S3 policy below will give the user full access only to bucket1.
NOTE: At the time of writing there is actually no way to prevent all buckets from being listed, so if you have lots of buckets in your account, then the user will see all the buckets but will only have access to bucket1.
You would do the following if you wanted to give the user access to bucket1.
1. create the bucket
2. create the user
3. apply the policy to the user
You dont need to give the bucket any policy or add the user to a group.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
"Statement": [
{
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
},
{
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::bucket1"
},
{
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::bukcet1/*"
}
]
}
Froling.bee.pl Hack Warning – this can destroy your seo and credibility with out you even knowing
15/2/2012 external link
I am highlighting today a very naughty but very genius hack I have found on one of my clients accounts. Its genius in the fact that it totally bypasses any client side malware detection scripts and naughty in the fact that it can:
destroy any seo you have done on your site
steals your clients by sending them to a possible “drive by install” site
reduce your sites credibility to rubble
All of this without you or your webmaster or seo dude/dudess being aware of it.
FYI: any linux server that I run, I run linux malware detect which is without a doubt a brilliant tool for spotting hacked files and without it, I probably would have never even found this hack.
Today I received a maldet report which showed one of my clients accounts as being compromised with some base64 code. Base64 code is not necessarily malicious, but, some investigation should be merited because it can contain dodgy code with a hidden agenda.
Here is a part of the maldet report I received today.
So the first thing I did was visit the clients site by typing their domain name into my browser and then doing “view source”, in order to see within the code of the site if there was any javascript injections, which is usually a sign that the site has been hacked in some way. I did not see any malicious code at all.
I then opened up the hacked files in notepad to discover some bas64 code had been inserted into every single php file on the clients site (not only wordpress files, even non wordpress files too) and its only then the situation has unravelled itself.
Next thing I did in order to test if this hack was working/real/functional, was to type into google search bar, site:clientsdomain.com, this then brings up all the listings that google has for this web site, allowing me to test the code.
I then clicked on one of the listing and lo and behold was auto redirected to a coupon site, not my clients site. I then tried it again with a different google link and I was redirected to a bing lookalike site. This is obviously very bad in the fact that normal visitors to your site will not see anything or be affected at all but anyone coming from bing, yahoo, facebook and google will simply be redirected, meaning any seo you have done in order to boost your serps get blown out of the water…not good.
So obviously as every single php file was infected, editing each file would prove to be futile, we simply restored the site from a backup and then investigated as to how the hacker has gotten in and found it was due to some permission issues with the clients account.
It does highlight a few things though in terms of how you could unwittingly be a victim of a hack and not even know it.
Connect 32 bit Classic ASP Page on 64 bit Windows Server to Remote MYSQL Database
27/7/2011 external link
In my company, for our windows machines, we have started to ditch 32 bit OS in favour of 64 bit systems, purely because 64 bit is more scaleable in terms of RAM and CPU for the hungry .asp and .net sites.
One issue I came across today was a customer asking how he can connect his classic asp pages to a remote mysql database.
Despite the server being 64 bit Windows 2008 R2 his site is running in 32 bit mode so we needed to install 32 bit drivers.
So here is what I did and it worked great.
1. installed the 32 bit version of the mysql odbc connector from http://www.mysql.com/downloads/connector/odbc/#downloads
2. in windows explorer, navigated to the syswow64 folder at c:/windows/syswow64/ (this is where all the 32 bit applications are installed)
3. scrolled down to odbcad32.exe and executed it
4. the 32 bit odbc manager popped up and I set up the connection as a dsn
I then created a test classic asp page on the server using dsn connection and it connected without any fuss.
The confusion I had initially was I was trying to configure the 32 bit connection via the 64 bit odbc manager, it was just not working at all, its only when I set the dsn up via the 32 bit odbc manager, everything purred perfectly.
Moving a SQL Database from Server A to Server B
10/7/2011 external link
If you need to move a sql database from one server to another and retain the usernames, schemas and passwords from Server A over to Server B, then this is the least complicated method.
Here I will show you how to move ONE SINGLE database using the .bak method and a couple of copy and pastes in the sql query editor. The whole process should not take more than a few minutes max which allows the minimum amount of downtime on your sql database.
You would need to have root access to server A and server B for this to work so this tutorial is really for system administrators not your general shared hosting user.
Do the following in this order.
On server A make a backup in .bak format of the database you wish to move.
On server A run the query below which creates 2 stored procedures (sp_hexidecimal + sp_help_revlogin).
On server A run this query “EXEC sp_help_revlogin”
Open Notepad and copy and paste the results generated by sp_help_revlogin on server A as you will need them later.
Move the .bak file from server A to server B and restore the database on server B
On server B, open the query editor and select the database from the list of databases.
In the notepad file you made earlier, look inside it for the line which says something like
CREATE LOGIN [the_db_username] WITH PASSWORD = 0x0100F2B6R825F8D48E446AE9625794253C4F473F5C7618A587348 HASHED, SID = 0x4CD3128A8CC68C418865FBD4A4958782, DEFAULT_DATABASE = [the_database_name], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
Copy the above query into the query editor on server B and execute it
Everything should work fine.
This is the query for step 2 that you need to run on server A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
USE master
GO
IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL
DROP PROCEDURE sp_hexadecimal
GO
CREATE PROCEDURE sp_hexadecimal
@binvalue varbinary(256),
@hexvalue varchar (514) OUTPUT
AS
DECLARE @charvalue varchar (514)
DECLARE @i int
DECLARE @length int
DECLARE @hexstring char(16)
SELECT @charvalue = '0x'
SELECT @i = 1
SELECT @length = DATALENGTH (@binvalue)
SELECT @hexstring = '0123456789ABCDEF'
WHILE (@i BEGIN
DECLARE @tempint int
DECLARE @firstint int
DECLARE @secondint int
SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))
SELECT @firstint = FLOOR(@tempint/16)
SELECT @secondint = @tempint - (@firstint*16)
SELECT @charvalue = @charvalue +
SUBSTRING(@hexstring, @firstint+1, 1) +
SUBSTRING(@hexstring, @secondint+1, 1)
SELECT @i = @i + 1
END
SELECT @hexvalue = @charvalue
GO
IF OBJECT_ID ('sp_help_revlogin') IS NOT NULL
DROP PROCEDURE sp_help_revlogin
GO
CREATE PROCEDURE sp_help_revlogin @login_name sysname = NULL AS
DECLARE @name sysname
DECLARE @type varchar (1)
DECLARE @hasaccess int
DECLARE @denylogin int
DECLARE @is_disabled int
DECLARE @PWD_varbinary varbinary (256)
DECLARE @PWD_string varchar (514)
DECLARE @SID_varbinary varbinary (85)
DECLARE @SID_string varchar (514)
DECLARE @tmpstr varchar (1024)
DECLARE @is_policy_checked varchar (3)
DECLARE @is_expiration_checked varchar (3)
DECLARE @defaultdb sysname
IF (@login_name IS NULL)
DECLARE login_curs CURSOR FOR
SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM
sys.server_principals p LEFT JOIN sys.syslogins l
ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name <> 'sa'
ELSE
DECLARE login_curs CURSOR FOR
SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM
sys.server_principals p LEFT JOIN sys.syslogins l
ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name = @login_name
OPEN login_curs
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin
IF (@@fetch_status = -1)
BEGIN
PRINT 'No login(s) found.'
CLOSE login_curs
DEALLOCATE login_curs
RETURN -1
END
SET @tmpstr = '/* sp_help_revlogin script '
PRINT @tmpstr
SET @tmpstr = '** Generated ' + CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'
PRINT @tmpstr
PRINT ''
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT ''
SET @tmpstr = '-- Login: ' + @name
PRINT @tmpstr
IF (@type IN ( 'G', 'U'))
BEGIN -- NT authenticated account/group
SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' FROM WINDOWS WITH DEFAULT_DATABASE = [' + @defaultdb + ']'
END
ELSE BEGIN -- SQL Server authentication
-- obtain password and sid
SET @PWD_varbinary = CAST( LOGINPROPERTY( @name, 'PasswordHash' ) AS varbinary (256) )
EXEC sp_hexadecimal @PWD_varbinary, @PWD_string OUT
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
-- obtain password policy state
SELECT @is_policy_checked = CASE is_policy_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name
SELECT @is_expiration_checked = CASE is_expiration_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name
SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' WITH PASSWORD = ' + @PWD_string + ' HASHED, SID = ' + @SID_string + ', DEFAULT_DATABASE = [' + @defaultdb + ']'
IF ( @is_policy_checked IS NOT NULL )
BEGIN
SET @tmpstr = @tmpstr + ', CHECK_POLICY = ' + @is_policy_checked
END
IF ( @is_expiration_checked IS NOT NULL )
BEGIN
SET @tmpstr = @tmpstr + ', CHECK_EXPIRATION = ' + @is_expiration_checked
END
END
IF (@denylogin = 1)
BEGIN -- login is denied access
SET @tmpstr = @tmpstr + '; DENY CONNECT SQL TO ' + QUOTENAME( @name )
END
ELSE IF (@hasaccess = 0)
BEGIN -- login exists but does not have access
SET @tmpstr = @tmpstr + '; REVOKE CONNECT SQL TO ' + QUOTENAME( @name )
END
IF (@is_disabled = 1)
BEGIN -- login is disabled
SET @tmpstr = @tmpstr + '; ALTER LOGIN ' + QUOTENAME( @name ) + ' DISABLE'
END
PRINT @tmpstr
END
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin
END
CLOSE login_curs
DEALLOCATE login_curs
RETURN 0
GO
Simple Abuse Monitoring Script in PHP for Cpanel
18/3/2011 external link
One of the issues with Cpanel servers, especially if you offer shared hosting, is to monitor the load averages as well as processes and identify resource abuse.
After having little luck in finding any decent monitoring scripts, especially ones which are easy to install, I have written a script in php which can be installed on a cpanel server as the root user and then executed using a cron to run it every 60 seconds.
Installation is simple:
1. adjust the destination email address
2. upload script to root directory
3. chmod the file to 755
4. create a cron job as root user to run the script every minute
IMPORTANT: This script will send you appx 1440 emails a day (60 per hour) and if you dont want to be reading all of them or having them fill up your inbox then you need to either set up a special mail account for it or adjust your own mail settings.
In my case I send the results of the script to my own main email address but I have created a folder inside my mail account called “server_checks” and created a mail rule to move these alert emails to the folder and to mark them as read.
So every day I just quickly scan to see if anything is out of the ordinary.
You could if you wanted to, adjust the script to drop the alert data into a remote database too if you did not want to receive emails!
Once installed, the script then sends an email every minute with a snapshot of the current mysql processes, load averages, current running processes giving you a rough idea what is happening on your server.
If you look at the image below, it shows the contents of a special mailbox I have set up which just gathers the abuse monitoring emails and you can see at a glance you can gauge the load averages for the server.
Below is the contents of the email and as you can see it contains various useful information about the server so in the case you notice at some point that there is some high load on the server, you can see the processes happening at that point in time.
Here is the script.
//#######################################################
// server load checker
// created by craigedmonds.com
// 1. upload this php script to /root
// 2. chmod the file to 755
// 3. in ssh type: crontab -u root -e
// 4. add this line: * * * * * /usr/bin/php /root/craigs-load-checker.php
// 5. restart cron service: /etc/init.d/crond restart
//#######################################################
//where we will send the emails
$email_to = “you@yourdomain.com”;
$email_from = “you@yourdomain.com”;
//#######################################################
//no need to edit below here
//#######################################################
$hostname = trim(shell_exec(‘hostname’));
$this_server_ip = gethostbyname(trim($hostname));
$mysql_processes = shell_exec(‘mysqladmin proc stat’);
$process_list = shell_exec(‘top -b -n 1′);
$uptime = shell_exec(‘uptime’);
$total_port80_connections= shell_exec(‘netstat -plan | grep :80 |wc -l’);
//get the load averages from the uptime
$explode_load_averages=explode(“load average:”,$uptime);
$explode_load_averages_again=explode(“,”,$explode_load_averages[1]);
$load_avg_current=trim($explode_load_averages_again[0]);
$load_avg_5mins=trim($explode_load_averages_again[1]);
$load_avg_15mins=trim($explode_load_averages_again[2]);
//send the email
$subject = $hostname . ” service CHECKER – ” . $uptime;
$address = $email_to;
$headers =
“From: ” . $email_from. “\r\n” .
“Reply-To: ” . $email_from. “\r\n” .
“X-Mailer: PHP/” . phpversion();
$body =”#SERVER_INFO\r\n”;
$body.=”Hostname: ” . $hostname . “\r\n”;
$body.=”IP: ” . $this_server_ip;
$body.=”\r\n\r\n”;
$body.=”#LOAD_AVERAGES\r\n”;
$body.=”Current Load Average: ” . $load_avg_current . “\r\n”;
$body.=”5 Minute Load Average: ” . $load_avg_5mins . “\r\n”;
$body.=”15 Minute Load Average: ” . $load_avg_15mins;
$body.=”\r\n\r\n”;
$body.=”#TOTAL_CONNECTIONS\r\n”;
$body.=”Port 80: ” . $total_port80_connections;
$body.=”\r\n\r\n”;
$body.=”#MYSQL_PROCESS_LIST\r\n”;
$body.= $mysql_processes;
$body.=”\r\n\r\n”;
$body.=”#PROCESS_LIST\r\n”;
$body.= $process_list;
$body.=”\r\n\r\n”;
$body.=”#end of notification”;
mail($address, $subject, $body, $headers);
exit;
Stop and Disable Mailman on Cpanel
5/1/2011 external link
One of our shared servers was showing several thousand bounce messages in the mail queue all generated via a mailman user. So we decided to kill mailman permanently.
However the recomended tweak of switching off Main >> Server Configuration >> Tweak Settings >> Mailman was not working. Still in the background there were mailman processes running, causing havoc.
So I needed to STOP mailman running as well as DISABLE it.
The solution I found was:
1. Run the following command in SSH which will stop the mailman process from running.
/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl stop
2. Create an .htaccess for mailman - Create a file at in the following location on your server.
/usr/local/cpanel/3rdparty/mailman/cgi-bin/.htaccess
3. Put the following code into the file, this will give a permission denied error on the mailman system.
<Limit GET POST>
order deny,allow
deny from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
4. Finally, add the .htaccess to the exclude file so cPanel won’t remove / change it. Run the following in SSH.
"/usr/local/cpanel/3rdparty/mailman/cgi-bin/.htaccess" >> /etc/cpanelsync.exclude
Bang! There you go. No more issues with mailman. Load dropped like a stone. Sweet!
Automatically Restart HTTPD when server overloads
8/11/2010 external link
I have several dedicated servers running WHM with cpanel on centos. I sell web space to the general public who with them bring their own developers and programmers and of course crappy code.
Quite often there will be sites that just EAT up CPU and of course I only know about it when the servers overloads itself and crashes. I do have CSF installed on all servers which does have an early warning system for server load, but if I am asleep in the middle of the night, its no help.
So, how can I prevent cpu overload on my server and bring my server back to normal use - AUTOMATICALLY?
After thoroughly looking around and it took me some time, I finally found some scripts I was looking for.
The scripts below is run by cron job every 60 seconds and detects the current server load. If the server load is above 25 then it will automatically stop the httpd server, send me an email informing me. Then 60 seconds afterwards, o the next cron run, it will check the server load again and if the server is back down to a load of 4 (an acceptable load on our system), the httpd service will automatically start again.
usually once httpd is stopped, the load drops down with 60/100 seconds so there is hardly anytime down time, but it does give you time to investigate where the issue is, especially if it happens all the time.
Totally perfect! It means that my system will not grind to a halt without me knowing. Its saved me a few times this month already since implementing it.
Obviously its not the be all and end all perfect solution, but it works and prevents serious overloading of the server.
This solution requires 4 different files to be installed on your server
click here to download related files (8kb zip format)
FILE 1: apache-load-checker.sh
FILE 2: apache-load-checker-notification-stopped.php
FILE 3: apache-load-checker-notification-restarted.php
Create/Install the above files in Home/root/ on your server.
FILE 4: apache-load-checker-cron
Create/Install this file into /Home/etc/cron.d. This will be the cron file
Just edit the files with your own email alerts etc.
Good luck with it!
PS: there is also another script over here which looks promising: http://blog.dhampir.no/content/how-to-kill-a-process-that-uses-too-much-cpu




