PHP session folder chmod

Support/Development for PHP
bob83
Forum User
Forum User
Posts: 33
Joined: Wed Oct 28, 2009 8:42 pm

PHP session folder chmod

Unread post 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?
prupert
Forum Regular
Forum Regular
Posts: 573
Joined: Tue Aug 01, 2006 2:45 pm
Location: Netherlands

Re: PHP session folder chmod

Unread post 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.
Lemonbit Internet Dedicated Server Management
bob83
Forum User
Forum User
Posts: 33
Joined: Wed Oct 28, 2009 8:42 pm

Re: PHP session folder chmod

Unread post 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.
jas8522
Forum User
Forum User
Posts: 52
Joined: Mon Jan 09, 2006 4:02 pm

Re: PHP session folder chmod

Unread post 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.
Post Reply