0

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 /var/log/apache2/error.log:

[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?

nicoco
  • 157
  • 2
  • 2
  • 9
  • I am running several Debian 8 apache+php systems. drwx-wx-wt` is the distro default for `/var/lib/php5/sessions/` and works perfectly fine for our PHP sessions. I am a bit confused why that session is owned by `nicoco` and not `www-data`, which is the default apache service account. – Zoredache Oct 12 '16 at 19:46
  • The `Permission denied (13)` in the error log is the telling message. Apache logs this message *only* when it has been denied by the OS from reading/writing to the file system. So either file/directory permissions or something like `SELinux`. It is *not* an Apache configuration problem, even if it looks like one. If everything *seems* right then one of your assumptions is wrong. – Unbeliever Oct 12 '16 at 20:08

1 Answers1

0

I finally figured this out.

As the comments pointed out, the file permissions weren't OK at all, I solved the problem by a neat rm /var/lib/php5/sessions/*.

I was using phpstorm's builtin web server before and switched to apache, I think that's why the permissions were messed up. Now I believe this is more normal:

# ls -l /var/lib/php5/sessions/
total 4
-rw------- 1 www-data www-data 115 oct.  14 20:18 sess_jo5m5mu4q8kehebcmumv9o8bs0
nicoco
  • 157
  • 2
  • 2
  • 9