Pages

Monday, April 1, 2013

Fatal error: Allowed memory size of xxxxxxxx bytes exhausted If deactivating plugins doesn’t work try one of these methods for increasing the amount of memory a PHP script may consume

1. If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 64M:
memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

2. If you don’t have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M

3. Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define(‘WP_MEMORY_LIMIT’, ’64M’);

How to clear eximstats db

If the size of your eximstats database is getting large, you can do the following steps to clear it.

Login to mysql

mysql

mysql> use eximstats
mysql> delete from sends;
mysql> delete from smtp;
mysql> delete from failures;
mysql> delete from defers;

Load due to a particular domain in the server

Whenever the load in the server increases due to a particular user in the server. Check the following:

Find the domain owned by the user:

grep username /etc/userdomains

use the following command after you get the domain name:

less /usr/local/apache/domlogs/domain.com | awk ‘{print $1}’ | sort | uniq -c | sort -n

This will give the ip and number of connections in the descending order. For example:
 13832 65.52.110.145
19112 66.249.68.183
208262 157.55.16.55

In the above case we can see too many connections from those ips. This is surely abnormal. Immediately block such ips in the server using csf

csf -d IP

[if not present use iptables].

SAMPLE PHP SCRIPT FOR SENDING MAILS

<?php

$Subject=”Trying to send”;
$Sender=”testing@betsexperts.com”;
$SendTo=”testmail4us@gmail.com”;
$Message2=”Testing mail”;

if(mail($SendTo, $Subject, $Message2, “From: $Sender”)){
print”<br><br><FONT style=\”font-size:12px\” color=\”#009300\” face=\”Arial\”><B>Sent to: $SendTo  … Sender: $Sender</B></FONT>”;
}else{
print”<br><br><FONT style=\”font-size:12px\” color=\”#FF0000\” face=\”Arial\”><B>Not sent to: $SendTo  … Sender: $Sender</B></FONT>”;
}

?>

Tips to remember:

Step 1:
Create a test.php inside public_html folder
For example —>  /home/public_html/test.php
Step2:
Copy the above script and paste inside test.php  (remember to change the ownership of test.php)
Step3:
run the url 
For example—> if you are creating test.php in your website http://example.com
Run the url as http://example.com/test.php
The mail will automatically send as php

How to redirect a WWW?

Step1:
Go to the path #/home/username/public_html

Step2:
vi .htaccess

Step3:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^hashroot.com\.com$ [NC]
RewriteRule ^(.*)$ http://www.hashroot.com/$1 [R=301,L]

Awstat is not showing correct count for a particular domain

Run the below script for which the domain is affected.

#/usr/local/cpanel/base/awstats.pl -config=domainname.com

website appear’s to be loading slow?

Speed it up using gzip compress and mod_deflate. Add the following code in the .htaccess file under website folder, save it . Site should be loading pages significantly faster now!

### Enable gzip compression for PHP files
php_value output_handler ob_gzhandler

### compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

### End of compression code