Page 1 of 1

PHP session folder chmod

Posted: Sun Dec 15, 2013 7:25 pm
by bob83
Since last php update ive trouble on some sites.
Problem: permission denied for sessions

Ive seen sessions are written to /var/lib/php/session.
Now, to solve this problem i chmod 777 this folder.
Is this a safe solution?

Re: PHP session folder chmod

Posted: Mon Dec 16, 2013 8:03 am
by prupert
No, it's not.

If you are running PHP applications under their own user (e.g. under FastCGI in stead of Apache/mod_php), you should define them their own session.save_path.

Re: PHP session folder chmod

Posted: Mon Dec 16, 2013 9:04 am
by bob83
Thanks, your post was very helpful to me.
Ive changed the original sessions folder to 0770 and use session.save_path like you suggest, its working fine.

Re: PHP session folder chmod

Posted: Fri Dec 20, 2013 12:41 am
by jas8522
If you don't wish to define a separate session save folder for each domain, you can set the permissions as follows:


chmod 733 /var/lib/php/session
chmod +t /var/lib/php/session

+t sets the sticky bit for the directory such that when the sticky bit is set, only the item’s owner, the directory’s owner, or the superuser can rename or delete files.