kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Moving mod_pagespeed’s file-based cache into RAM

Posted on January 27, 2012

Google's mod_pagespeed does a great job at optimising web resources such as HTML, JS, CSS and even images.
I use it on a lot of customer production sites as a great partner to APC cache for super fast web sites.

I won't go into details on how it works, if you're  reading this, you already know!

mod_pagespeed caches resources to disk. If you are running on a heavily loaded server or a VPS, disk IO is a premium.
So we should really cache to memory, its faster, cheaper and easy to set up.

Disabling Core Dumps

Posted on August 17, 2011

I recently found a (cPanel) server was generating over 100Gb of core dumps every time a bad PHP script died or Apache died. Writing these generally useless (who actually debugs these on a live web server) to disk is a pointless waste of disk I/O, especially in a VPS environment.

Here is two methods of disabling core dumps;

Disabling Dangerous PHP Functions in a Shared Environment

Posted on July 15, 2011

PHP is an incredibly versatile language and if used in the wrong way, either maliciously or by accident has the potential to mess up an entire webserver. This can be a major problem if you are offering a shared hosting environment.

There is an often overlooked php.ini setting called disable_functions at hand.

cPanel Apache Tuning

Posted on November 22, 2010

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.

PCI Compliance – Disable SSLv2 and Weak Ciphers

Posted on November 6, 2010

Section 4.1 of the the Payment Card Industry Data Security Standard (PCI-DSS) v1.2, merchants handling credit card data are required to “use strong cryptography and security protocols such as SSL/TLS or IPSEC to safeguard sensitive cardholder data during transmission over open, public networks.”

Apache redirects based on IP Address/Subnet

Posted on November 5, 2010

Ever needed to redirect a source IP address or source subnet in apache?

Why? Redirect annoying spam bots, users or other individuals away from your blog for example.

Slam the following code into your .htaccess file or VirtualHost Directive.

Tagged as: Continue reading

[Snippet] Where are my cPanel logs at?

Posted on November 4, 2010

You've got a main error log at /etc/httpd/logs/

And cPanel's logs are in /usr/local/cpanel/logs/

Filed under: Apache, cPanel/WHM No Comments

Smarty Security – Stop .tpl access

Posted on August 17, 2010

WHMCS uses the Smarty template engine. Which means your .tpl files are accessible to anyone that knows the path. Quite easy in WHMCS. Whilst not really a major security risk, its bad practise to all these files to be accessed directly.

Add this code into your .htaccess file.

  1. <Files ~ "\.tpl$">
  2. Order allow,deny
  3. Deny from all
  4. </Files>
Tagged as: No Comments

[Snippet] Redirecting Non-SSL Traffic to SSL

Posted on June 15, 2010
  1. RewriteEngine On
  2. RewriteCond %{HTTPS} off
  3. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Filed under: Apache No Comments

Redirecting non-www to a www prefix

Posted on May 22, 2010

This old chestnut again.

Create or edit the .htaccess file

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} !^www\.YOURDOMAIN\.COM$ [NC]
  3. RewriteRule ^(.*)$ http://www.YOURDOMAIN.COM/$1 [R=301,L]
Tagged as: , No Comments
Page 1 of 212