Lighttpd beware of default php session path permission

by nixcraft · 3 comments

Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.

This path is defined in /etc/php.ini file and all data related to a particular session will be stored in a file in the directory specified by the session.save_path option.

After installing phpMyAdmin I was able to login but unable to select or modify tables. First, I thought I made some configuration errors, and then I reinstalled phpMyAdmin again. It was not working at all.

Finally, log file scripts.log (php error log file) provides me the answer. It was full of following errors:

[26-Jul-2006 13:35:22] PHP Warning:  Unknown: open(/var/lib/php/session/sess_lLFJ,tk9eFs5PGtWKKf559oKFM3, O_RDWR) failed: Permission denied (13) in Unknown on line 0
[26-Jul-2006 13:35:22] PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0
[26-Jul-2006 13:35:40] PHP Warning:  Unknown: open(/var/lib/php/session/sess_lLFJ,tk9eFs5PGtWKKf559oKFM3, O_RDWR) failed: Permission denied (13) in Unknown on line 0

/var/lib/php/ has root:apache write permission combination. Since I had migrated from Apache to lighttpd web server, I just forgot to set correct permission for session directory (php.ini - session.save_path directive). To change file owner and group permission you need to use chown command as follows:

# chown root:lighttpd /var/lib/php/ -R

Now phpMyAdmin is working fine.

Squid 2.6 stable issues

On a related note, there are some serious issues with Squid v2.6Stable1. This version is badly broken. It was sending few client browser error 400 (no log was generated for these errors) or does not display images at all causing problem for 500+ users (and not to mention lots of headache for me). Therefore, I had to switch back to 2.5.STABLE13. Thanks to backup, I was able to switch back within 15 minutes to old version :D

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 3 comments… read them below or add one }

1 itamar 05.24.07 at 1:58 am

I belive the best option is add lighttpd to group apache.

2 Misinformed 02.07.08 at 4:52 pm

Genius. Thanks for the tip.

3 Rey 04.05.09 at 1:30 pm

try chmod 1777 /var/lib/php/session

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: