Hosting

PHP Host Settings Without phpinfo()


Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes.

<?php
$d_func = ini_get("disable_functions");
$up_max = ini_get("upload_max_filesize");
$up_max = str_replace("M","",$up_max);
$up_max_size = "Megabytes";
$post_max = ini_get("post_max_size");
$post_max = str_replace("M","",$post_max);
$post_max_size = "Megabytes";
$input_max = ini_get("max_input_time");
$mem_limit = ini_get("memory_limit");
$mem_limit = str_replace("M","",$mem_limit);
$mem_limit_size = "Megabytes";
$exec_time = ini_get("max_execution_time");
$safe_mode = ini_get("safe_mode");

if(!is_null($d_func) && $d_func !== ""){echo "Disabled Functions: \n $d_func";}
if(!is_null($safe_mode) && $safe_mode !== ""){echo "<span style='color:red;'>Safe Mode is Active</span> <br>";}
if($up_max >= 1001){$up_max = $up_max / 1024; $up_max_size = "Gigabytes";
if($up_max >= 10001){$up_max = $up_max / 1024; $up_max_size = "Terabytes";}}
if($post_max >= 1001){$post_max = $post_max / 1024; $post_max_size = "Gigabytes";
if($post_max >= 10001){$post_max = $post_max / 1024;$post_max_size = "Terabytes";}}
if (min($input_max,60)){$input_max = $input_max /60;}
if (min($exec_time,60)){$exec_time = $exec_time /60;}
if($mem_limit >= 1001){$mem_limit = $mem_limit / 1024; $mem_limit_size = "Gigabytes";}

echo "Maximum Upload Size = $up_max $up_max_size<br>";
echo "Maximum Post Size = $post_max $post_max_size <br>";
echo "Maximum Input Time = $input_max minute/s<br>";
echo "Memory Limit = $mem_limit $mem_limit_size<br>";
echo "Maximum Execution Time = $exec_time minute/s<br>";
?>

PHP Host Settings Without phpinfo() Read More »

.htaccess Mod-Rewrites for WWW Domain Name Prefixes


Quite some time ago now I wrote about the importance of 301 redirects for SEO purposes.
In a minor addition to that post here is a snippet I often use to ensure search engines do not view http://yourdomain.com and http://www.yourdomain.com as duplicate content.

To perform a redirect from domain.com to www.domain.com, insert the following code into your .htaccess file.

# mod_rewrite in use
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

To perform a redirect from www site to non-www site, use the following code in .htaccess file.

# mod_rewrite in use
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301, L]

.htaccess Mod-Rewrites for WWW Domain Name Prefixes Read More »

Mail, Google Apps, Cpanel, and SPF

Sender Policy Framework (or SPF) is an email validation system designed to addressing source address spoofing. It allows administrators to specify which hosts are allowed to send email from a given domain by creating a specific DNS SPF record in the public DNS. Mail exchangers can then check that mail from a given domain is being sent by a host sanctioned by that domains administrators.

So, after setting up mail from Google apps you’re getting this error:
(IP addresses and domains have been changed to protect the innocent)

SMTP error from remote mail server after RCPT TO:<email@domain.com>:
host something.email.com [127.0.0.1]: 550 <email@domain.com>:
Recipient address rejected: undeliverable address:
host domain.com[127.0.0.1] said: 550-something.email.com [127.0.0.2] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client. (in reply to RCPT TO command)

You check your DNS records and everything seems to be in order…
You’ve changed your cname for mail to point to Google: ghs.google.com
You’ve changed your MX records for your domain to point to Googles: aspmx.l.google.com etc
You’ve configured your server in Cpanel to act as a Remote Mail Exchanger

For Google to accept your mail server as a relay, you need to enter a line in your DNS zone:
yourdomain.com TXT v=spf1 include:_spf.google.com ~all
(Do not use the built in SPF in Cpanel, and you may need your host to enter this line for you)

A little info is here for Google Support
Background reading in SPF in Wikipedia is here

Mail, Google Apps, Cpanel, and SPF Read More »