hotfix: enable PHP session garbage collection on OpenLiteSpeed stack - #20
hotfix: enable PHP session garbage collection on OpenLiteSpeed stack#20nabil1440 wants to merge 1 commit into
Conversation
lsphp installs Debian's php.ini-production, which sets session.gc_probability = 0 and offloads cleanup to a sessionclean cron that is not present in the OpenLiteSpeed container. With built-in GC disabled and no cron running, stale sess_* files accumulate in /var/lib/php/sessions indefinitely. Re-enable PHP's probabilistic GC via ols.ini, which is mounted into lsphp's config scan dir and overrides the base php.ini. Fixes flywp/flywp-client-issues#48
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughPHP session garbage collection is explicitly configured in ChangesSession garbage collection
Estimated code review effort: 1 (Trivial) | ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Issue
Ref: flywp/flywp-client-issues#48
On the OpenLiteSpeed (OLS) stack, PHP session files pile up in
/var/lib/php/sessionsindefinitely — no garbage collection ever runs atthe PHP/OLS layer, unlike nginx sites which clean up normally.
Root cause: lsphp installs Debian's
php.ini-production, which shipssession.gc_probability = 0. That is Debian's convention because it offloadssession cleanup to a
sessioncleancron job. But that cron is not present inthe OLS container, the bundled
sessioncleantargets apache2/cgi/fpm SAPIpaths that do not exist in the lsws layout, and no cron daemon runs in the
container anyway. With built-in GC disabled and nothing replacing it, stale
sess_*files accumulate forever. (nginx sites build onphp:*-fpm-alpine,which ships no
php.ini, so PHP's compiled defaults keep GC enabled.)Fix
Re-enable PHP's built-in probabilistic session GC via
php/ols.ini:session.gc_probability = 1session.gc_divisor = 100session.gc_maxlifetime = 1440ols.iniis bind-mounted into lsphp's config scan dir(
.../lsphpXX/etc/php/X.Y/mods-available/), which overrides the basephp.ini, so these values take effect on the next lsphp restart. New OLSsites pick this up on clone; existing sites on their next
update-php.shrun.Summary by CodeRabbit