“sh: -t: command not found” with PHP cron/command line

Are you getting “sh: -t: command not found” when running a PHP from cron or command line? This usually occurs when your accessing PHP’s mail() function with no (compatible) mail server installed on the server.

Here’s my CentOS based solution. Continue reading ““sh: -t: command not found” with PHP cron/command line”

Passing Every ~ \.php$ request to to PHP

It is common with Nginx to pass every URI ending in .php to the PHP parser, if using a default PHP build this might lead to security issues. Nginx is a reverse proxy and as such does not have a concept of file unless you specifically tell it to. So if your configuration looks like this.

Continue reading “Passing Every ~ \.php$ request to to PHP”

[Snippet] Formatting an IMEI Number in PHP

Formatting an IMEI number in PHP is reasonably simple. The IMEI (14 decimal digits plus a check digit) or IMEISV (16 digits) includes information on the origin, model, and serial number of the device.

The format of the IMEI is AA-BBBBBB-CCCCCC-D, although it may not always be displayed this way. The IMEISV drops the Luhn check digit in favour of an additional two digits for the Software Version Number (SVN), making the format AA-BBBBBB-CCCCCC-EE

 

Continue reading “[Snippet] Formatting an IMEI Number in PHP”

Not your usual WordPress IO Error

Today I noticed I was getting the dreaded WordPress IO Error when uploading media. I’ve fixed this before, for me and other clients but this wasn’t the usual error.

Not  file permissions, not an anally retentive PHP install, not user error. Besides, media uploads worked via the HTTP uploader, just not the Flash uploader. Continue reading “Not your usual WordPress IO Error”

Truncate a string to the nearest word

Truncating a string in PHP is easy, substr($start,$finish), but its annoying when it truncates the string mid-word isn’t it? Here’s how I overcame the issue to truncate the string to the nearest word.

This is a modified function found on the PHP site. Continue reading “Truncate a string to the nearest word”

cPanel Apache Tuning

One of the first things I do is run /scripts/easyapache and rebuild my PHP / Apache configuration.
I usually select Apache 2.2 and PHP 5.2.9. At the time of writing I stay away from the 5.3 versions as they aren’t supported by programs and programmers enough yet.

Although this guide was originally inspired from a cPanel install, its Apache specific and doesn’t require cPanel.

  1. Continue reading “cPanel Apache Tuning”

Installing memcached on CentOS/cPanel

memcached a (distributed) memory object caching system vital if your running a HA Linux* setup or a web farm. Or even if you need fast as **** caching for an application.

Consider it extra memory for your server, so you can cache more, for example large arrays, SQL queries and other stuff!

* Actually I’ve discovered there are memcached extensions for Java, C & .NET. Wow, it just grew up!

Continue reading “Installing memcached on CentOS/cPanel”

Installing memcached on CentOS (cPanel)

Welcome to hell. No really, compared to installing memcached on Ubuntu, CentOSs really sucks. CentOS really sucks for package management.  Really sucks. Anyway, on to the point.

Here’s how I installed memcached on CentOS, which I mainly use for cPanel. Continue reading “Installing memcached on CentOS (cPanel)”