syntaxseed,
@syntaxseed@phpc.social avatar

So I have a Wordpress website which is deployed to the apache+nginx server with Ansible. A symlink in the webapp's document root is updated to point to the new release.

I'm encountering Apache (I think) caching the results and serving the index.php page in the old release until I modify the file. Even though the symlink points to the new release.

Any suggestions as to how to fix this other than tweaking the modified date on the old release?

#PHP #Devops #Ansible #Webdev

syntaxseed,
@syntaxseed@phpc.social avatar

Definitely seems to be an opcache issue. And setting opcache.revalidate_path=1 in the global php.ini settings works.

However this server is managed by Runcloud and I'd rather not override their config. Will have to test more with it set locally in php.ini within the app.

contortion,

@syntaxseed

Depending on what you're deploying with you could clear the opcache with a command like service php-fpm reload on the server after the releases are switched.

michael,
@michael@thms.uk avatar

@syntaxseed that also seriously impacts performance in my experience (though how seriously probably depends on your setup / traffic levels / etc). Which is why I’m suggesting to reload php-fpm during deployment if you can.

sebobo,

@syntaxseed the PHP realpath setting could help, checkout this blog post https://sandstorm.de/de/blog/post/realpath-cache-in-depth-or-fixing-a-tricky-neos-deployment-issue.html

Or you flush the PHP opcache, which should also help.

michael,
@michael@thms.uk avatar

@syntaxseed not usually dealing with apache, but I usually restart php-fpm during each deployment, just to be sure opcache doesn’t mess things up

scanton,
@scanton@mstdn.social avatar

@syntaxseed maybe 'apache graceful' helps you after you publish the new release files

josh,
@josh@joshbutts.social avatar

@syntaxseed @grmpyprogrammer A best practice is to just soft-restart apache upon deployment. You're probably experiencing the PHP opcache.

syntaxseed,
@syntaxseed@phpc.social avatar

@josh @grmpyprogrammer I agree. I think this is it. But I'm trying not to need root for my deploy script. Still investigating but getting closer!

josh,
@josh@joshbutts.social avatar

@syntaxseed @grmpyprogrammer You can clear the opcache from a php script without needing root. You’d need to be smart about how you protect it, but you could just create an opcache_reset.php in your document root that calls this function and hit it with curl or something. https://www.php.net/manual/en/function.opcache-reset.php

omerida,

@syntaxseed @josh @grmpyprogrammer something related to symlink deploys turns up on internals too: https://externals.io/message/107650#107725 seems like it relies on realpath cache: https://engineering.facile.it/blog/eng/realpath-cache-is-it-all-php-opcache-s-fault/

willpower232,
@willpower232@phpc.social avatar

@syntaxseed @josh @grmpyprogrammer I have a similar situation from years ago and the only solution I found was to allow the user sudo powers only for reloading php-fpm 😬

syntaxseed,
@syntaxseed@phpc.social avatar

@josh @grmpyprogrammer

Found the best way was a local webapp override which is found in another location (for servers managed by Runcloud) and setting opcache.revalidate_path=1 solved it.

barbanet,

@syntaxseed Is something special being used for cache? Maybe OpCache?

fsniper,
@fsniper@mastodon.social avatar

@syntaxseed I haven't used apache for a long long while so I can't talk about the behaviour. However I can suggest a "touch symlink" to update the modified time of the symlink.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • provamag3
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • megavids
  • Leos
  • cisconetworking
  • JUstTest
  • lostlight
  • All magazines