Common Issues
PHP Session Filling up /tmp
When installing openlitespeed, you might run into an issue where the /tmp directory is full and has 100000 sess_ files from PHP.
This is due to the fact that there is no mechanism to remove these files on a regular basis. There is a mechanism within Ubuntu for apache and php-fpm but not openlitespeed. You can use the following commands to create a service that runs and clears out the files.
systemctl stop phpsessionclean.service
systemctl disable phpsessionclean.service
systemctl stop phpsessionclean.timer
systemctl disable phpsessionclean.timer
echo "*/30 * * * * root find -O3 '/tmp' -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin +180 -delete" > /etc/cron.d/openlitespeed-phpsessionclean
In the above code, the following occurs.
- The first 4 commands are to disable the
phpsessionclean
service and timer, which normally runs the/usr/lib/php/sessionclean
script.
This is the contents of the phpsessionclean.service file
[Unit]
Description=Clean php session files
[Service]
Type=oneshot
ExecStart=/usr/lib/php/sessionclean
ProtectHome=true
ProtectSystem=true
PrivateTmp=true
- The final command creates the
/etc/cron.d/openlitespeed-phpsessionclean
cronjob file, which runs every 30 minutes and deletes php sessions files that had their status changed more than 180 minutes ago.