Moving PHP’s session storage to tmpfs

Open php.ini

vim /etc/php5/fpm/php.ini

Add following line.

session.save_path = "/var/run/php5/sessions"

Save and exit.

Run following commands.

mkdir -p /var/run/php5/sessions/
chown -R www-data:www-data /var/run/php5/
cp -rp /var/lib/php5/* /var/run/php5/sessions/
service php5-fpm restart

Edit cron on Debian/Ubuntu

vim /etc/cron.d/php5

Find 2 occurrences of /var/lib/php5/ and replace them with /var/run/php5/sessions/

This cronjob keeps deleting old sessions from time to time. If you forget to do this, you will get disk full error.

That’s it!

Discuss your project
with our experts

No obligation. Limited slots.

Contact Form Business Enquiry

"*" indicates required fields

Please attach any RFP, project specification, or document that you would like to share.
Drop files here or
Max. file size: 5 GB.
    This field is for validation purposes and should be left unchanged.