Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a PHP web application we are deploying to a LAMP server running CentOS 5.5 using Capistrano. Capistrano manages switching to the latest version (and rolling back) using a symlink, so our document root has to point to that symlink.

Unfortunately, we have been seeing that web requests to the PHP application still point to the previous target of the document root's symlink for exactly 60 seconds after the symlink is updated.

The only setting in the PHP config I could find that might relate to this is the realpath_cache_ttl setting, however this is set to 120 seconds. I couldn't find anything in apache's configuration.

We are not using APC.

Am I even looking in the right place?

share|improve this question
Is your document root located on a local hard drive, NFS or something else? – Janne Pikkarainen Jul 26 '11 at 7:45
The relevant fstab entry looks like this: "/dev/centos/slash / ext3 defaults 1 1". I guess it's on a local drive, but I could be misreading it - I don't know what /dev/centos/slash means. – Shabbyrobe Jul 26 '11 at 7:47
Yep, a local drive. There goes my theory about NFS cache. – Janne Pikkarainen Jul 26 '11 at 7:48
If you have apc check apc.stat = 0 in php.ini and change it to 0 to test this if not – Stewart Robinson Aug 3 '11 at 6:18
Thanks for the advice. I checked and we're not using the apc extension, though I'd prefer to be. I'll keep an eye on that setting when I set it up later. – Shabbyrobe Aug 3 '11 at 7:36

Symlinks are cached by Apache, I assume you are using FollowSymLinks in your httpd.conf. You could try using SymLinksIfOwnerMatch whose call to lstat is not cached

share|improve this answer

apache doesn't cache symlinks but it caches locations of files a bit and if you use APC it will really do some caching. I saw this also but used fabric for deploys. The work around was doing a apache restart/reload/graceful after the change symlink.

try a graceful first, then reload then restart if all else fails

share|improve this answer
Can apache be told to do any of those things when not running as root/sudo? It is not an option for me to sudo during routine capistrano deploys. – Shabbyrobe Jul 26 '11 at 23:02
You need to work with your sysadmin to devise a solution for this. – sciurus Aug 5 '11 at 18:44

Apache doesn't cache symlinks (it'd be incredibly stupid to try; the filesystem cache knows a lot more about what's going on, and would be very close to as fast). I'd strace the whole shebang to get a better idea of what's doing what when.

share|improve this answer
What does strace do exactly? Is it safe to run in production? This is a classic "happens in production only" issue. – Shabbyrobe Jul 26 '11 at 23:01
Questions go in questions, not comments. But really, man strace isn't hard. – womble Jul 26 '11 at 23:08
$ man strace No manual entry for strace. It's not available on my production systems. Requests for elaboration on your solution go in comments. – Shabbyrobe Aug 2 '11 at 4:30
Install strace. – womble Aug 3 '11 at 7:42
If you don't have root, you can't properly diagnose the problem anyway, so hand this over to the sysadmin to deal with. However, you don't need root to install software. – womble Aug 3 '11 at 7:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.