Apache cluster and php sessions

Discussion in 'HOWTO-Related Questions' started by stormrider, Sep 21, 2006.

  1. stormrider

    stormrider New Member

    Hello,

    I have followed this amazing howto (http://howtoforge.com/high_availability_loadbalanced_apache_cluster) to create my apache cluster. Almost everything seens to be working great (i'm already using unison to sincronyze files :) ).

    Then only problem is with php sessions. My users are always losing their sessions because they change servers. How do you solve this? How can i sincro sessions too?

    Thanks for any kind of help!
     
  2. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    You could configure your PHP applications to store the sessions in a MySQL database instead of in the file system.
     
  3. stormrider

    stormrider New Member

    Is there a simple way to do this? Something like just modifying php.ini or do i have to modify the source of the php script?

    Because i have lots of clients that use php and php sessions, so would be impossible to modify all the scripts.

    I have seen that php5 on Debian stores its session files in /var/lib/php5/. I tought about mounting this folder using nfs. So the sessions on each server would be synchronized. But them came another questions, i have two servers (server1 and server2) if i mount server1's folder on server2 and server1 goes down, so server2 would lost all sessions and my ha enviroment have a serious point of failure. Any ideas of how to solve this?
     
  4. Spudchat

    Spudchat New Member

    I use a setup kind of like yours, instead I have music instead of php sessions. Two machines run apache2, gnump3d, and heartbeat so that if one goes down the second will cover him. Instead of keeping the music locally and using a ton of harddrive space on both machines I use a third machine to export the NFS shares to the servers. For maximum tolerance I would like to add a fourth machine mirroring the NFS server in case it fails. Maybe this will give you some ideas.

    Spudchat
     
  5. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

Share This Page