I use

  • Centos 7 (latest update)
  • Apache 2.4.6
  • PHP 7.2

I would like to change the directory where sessions stored on the server, the default directory is /var/lib/php/session/, I can use this directory without any problem, but when I change the directory in PHP.ini file, I get an error :

session_start(): open(/var/www/session/sess_dug784eu96aj06eh1gte4hak2f, O_RDWR) failed: Permission denied (13)

I also edited php.conf inside /etc/httpd/conf.d and removed this line To stop session directory from being overridden :

php_value session.save_path    "/var/lib/php/session"

As you can see, I use /var/www/session/ as new directory to store sessions and this directory exist and have exactly same Permission as default directory :

0770 / owner : root / group : Apache

I also tried to copy the existing session file from default directory to the new directory, but I still get same error !

Thank you for your help.

  • What user/group is the PHP script running as?
    – womble
    Sep 3 '18 at 8:44
  • Under user and groupe Apache @womble
    – Sinf
    Sep 3 '18 at 9:11
  • Presumably it's an SELinux issue, then.
    – womble
    Sep 3 '18 at 9:14
  • Can you give me a clue how to find out please ? @womble
    – Sinf
    Sep 3 '18 at 9:16

Okay I found the solution, THX @womble to point where the problem is, I could at least search on the correct way,

In case if someone else have same problem, SELinux most be Disabled (which is not recommended), or it most be configured to allow Apache access the new directory :

chcon -t httpd_sys_rw_content_t /var/www/session -R

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.