I’m trying to set up a fonctionnal Apache2/PHP web server on my debian Jessie machine.
It seems I cannot handle session variables. These lines keep repeating in
[Wed Oct 12 19:11:24.828962 2016] [:error] [pid 28677] [client 127.0.0.1:50153] PHP Warning: session_start(): open(/var/lib/php5/sessions/sess_7o0m589ns0hhmafaht6cqvml35, O_RDWR) failed: Permission denied (13) in /home/nicoco/Documents/coloc-web/phpstorm-project/controller/main.php on line 2 [Wed Oct 12 19:11:24.829464 2016] [:error] [pid 28677] [client 127.0.0.1:50153] PHP Warning: Unknown: open(/var/lib/php5/sessions/sess_7o0m589ns0hhmafaht6cqvml35, O_RDWR) failed: Permission denied (13) in Unknown on line 0 [Wed Oct 12 19:11:24.829489 2016] [:error] [pid 28677] [client 127.0.0.1:50153] PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5/sessions) in Unknown on line 0
which is weird because the file permissions looks OK:
# ls -la total 12 drwx-wx-wt 2 root root 4096 oct. 12 17:50 . drwxr-xr-x 4 root root 4096 sept. 10 19:47 .. -rw------- 1 nicoco nicoco 202 oct. 12 19:05 sess_7o0m589ns0hhmafaht6cqvml35
As I’m completely new to both web server administration and PHP, it may be possible that the problem comes from my PHP code… Any hint?
The permissions are really not OK.
The session directory is readable and writable by root, but everyone else can only write to it. This is a problem because PHP needs to both read and write to the session files.
There are multiple ways to solve this, such as expanding the permissions or changing the group name, but I prefer setting an ACL on the directory so that it is writable by PHP (either by Apache with mod_php, or by php-fpm when using that).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.