Monthly Archives: October 2012

Install APC and fix “potential cache slam” problem

APC is an Alternative PHP Cache or Opcode cache that speeds up performance dramatically by caching queries.

How to install APC?

apt-get install php5-apc

You will have to enble it in the php configuration. Add the following to your php.ini file

extension=apc.so

Alternatively, you could create a separate apc.ini file and put it in the conf.d directory.

If your error log shows a lot of messages about potential cache slam averted, it is a bug. Not much you can do about it but you can turn slam defense off so that it doesn’t spam your logs (or cause other fails)

Add after that line in your php.ini or apc.ini

apc.write_lock = 1
apc.slam_defense = 0

How to install APC and fix “potential cache slam” problem

APC is an Alternative PHP Cache or Opcode cache that speeds up performance dramatically by caching queries.

How to install APC?

apt-get install php5-apc

or

pecl install apc

You will have to enble it in the php configuration. Add the following to your php.ini file

extension=apc.so

Alternatively, you could create a separate apc.ini file and put it in the conf.d directory.

If your error log shows a lot of messages about potential cache slam averted, it is a bug. Not much you can do about it but you can turn slam defense off so that it doesn’t spam your logs (or cause other fails)

Add after that line in your php.ini or apc.ini

apc.write_lock = 1
apc.slam_defense = 0

Then copy the apc.php file into a folder that is served by your webserver. Accessing this script in a browser gives you information on the state of your cache. However this script also allows viewing of the files cached and may be a security concern, so it is best kept in a folder with restricted access.

WordPress: Problem happened with plugin upgrade – can’t delete old files

When you get an error like this while updating, check file ownership. Chances are that you edited something in the backend and the plugin or theme files now being owned by another user, cannot be deleted by the server.

If you have terminal access as root, type:

chown -R www-data:www-data /path/to/wordpress/*

Where www-data is the user your Apache runs as and /path/to/wordpress is of course the path to the root of your wordpress installation. the “*” is to apply to all files and folders and the “-R” earlier means the command [chown – for change owner – in this case] applies recursively to all files and folders contained in the folder named.

If you try to upgrade now, it should work.

Varnish won’t start – Too many arguments (…)

So you set up Varnish. You really did everything right, but when you try to start it…

root@www:/etc/apache2/sites-available# service varnish start
* Starting HTTP accelerator varnishd [fail]
SMA.s0: max size 512 MB.
Too many arguments (...)
usage: varnishd [options] -a …

and so on, and you have tried and tried to edit /etc/default/varnish till you’re ready to give up?

Varnish works fine if you start it from the command line with configuration (as described in the documentation – for testing), but fails to start as a daemon?

The problem is some invalid characters related with line break in the /etc/default/varnish file. They seem to be there in the original file itself. I was not able to fix the characters, but simply editing the file so that the whole configuration appears as one line works.

So, for example:

DAEMON_OPTS="-a :80
-T localhost:1234
-f /etc/varnish/default.vcl
-s malloc,256m"

Becomes

DAEMON_OPTS="-a :80 -T localhost:1234 -f /etc/varnish/default.vcl -s malloc,256m"

This worked for me. If you don’t like this you could try fixing whatever the issue is with the linebreak. Do tell me if you figure it out.