Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
1  
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

3 Answers 3

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 http://httpd.apache.org/docs/2.0/misc/perf-tuning.html#symlinks

share|improve this answer

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
1  
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
2  
Questions go in questions, not comments. But really, man strace isn't hard. –  womble Jul 26 '11 at 23:08
1  
$ 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
1  
Install strace. –  womble Aug 3 '11 at 7:42
2  
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

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
1  
You need to work with your sysadmin to devise a solution for this. –  sciurus Aug 5 '11 at 18:44

Your Answer

 
discard

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.