Author Archives: admin - Page 2

Handling config files for local development, staging and production in PHP

I’ve had a few stabs at this and never been particularly happy with how it works. My last move was to only provide a skeleton config file under versioning, then complete variables like DB user and pass on individual servers. …

Read more »

Memcached logrotate

The Ubuntu package does not include a logrotate script for memcached. No idea why, but something like this might avoid the error I had yesterday. As /etc/logrotate.d/memcached /var/log/memcached.log { daily missingok rotate 10 compress delaycompress notifempty copytruncate }

Memcached constant timeouts and high load

Just a rather silly one… So the two webservers on one site started to run at a crawl. The timeout was so bad, the load balancer healthchecks were failing and they were up and down constantly. Lots of checking of …

Read more »

Preventing Site Cloning and DoS with Fail2Ban

This one came up as a result of the DoS attack last week when a site I administer was hit repeatedly for page downloads at the rate of 2 or 3 a second for a couple of hours. The same …

Read more »

DoS on Amazon EC2 instances running WordPress

I was got out of bed with an emergency call from a client at the weekend because his blog was down. This is the one that is getting a lot of traffic, but CPU was spiking up to 100% quite …

Read more »

Fail2Ban behind an Amazon Load Balancer

When using F2B on servers that sit behind Amazon ELBs (and probably load balancers of other types), the client IP in the error log is usually that of the load balancer. Banning the load balancer from access is probably not …

Read more »

Adding a new MySQL slave on EC2

There are a few posts around for doing this easily, but this has just worked nicely for me. This was done between two instances on Amazon EC2 cloud. On the existing slave (in mysql) SLAVE STOP; SLAVE SHOW STATUS\G; # …

Read more »

Turn PHP Xdebug profiling on and off by BASH script

It was bugging me (debugging me?) that Xdebug profiling dragged my development server down so much. So here’s a simple script to place in /usr/local/bin to turn it off and on more easily. Remember to chmod +x it first. This …

Read more »

Static variables in PHP functions

Today I had to pull an identifying array from a DB to be used by an inner loop to apply categories to some book details I was parsing. Clearly I wanted to build this array once so it had to …

Read more »

Using Fail2Ban to protect WordPress

I posted some previous ideas on this that were okay, but they turned out to be less-than-ideal solutions. They work, but one of the blogs I watch over is a bit busy, and having Fail2Ban watching the Apache access.log was …

Read more »