PHP changing session.save_path

Discussion in 'Installation/Configuration' started by drodrig, Oct 3, 2011.

  1. drodrig

    drodrig New Member


    I have recently begun using ISPConfig. It is working quite well, but I use a memcache server and therefore need to have the session.save_path php.ini parameter set to the appropriate string. The problem is that I'm using fast cgi and all the .php-fcgi-starter scripts contain a session.save_path parameter that trumps the one that I changed in php.ini.

    I can and have changed these scripts manually on a site-by-site basis. This is OK, but I'd rather the change take place through the ISPConfig interface. I tried removing the save_path param from:




    Yet I still get the default save_path param in php-fcgi-starter when I create a new site, so these must not be the correct files to modify.

    Your help is appreciated.
  2. Mark_NL

    Mark_NL Member

    I've tested this on my svn server and seems to work just fine.

    what i did:

    edit: /usr/local/ispconfig/server/conf/php-fcgi-starter.master
    -d session.save_path=<tmpl_var name='document_root'>/tmp \
    -d session.save_path=tcp:// \
    Then created a new website, and waiting for the cron to pick it up, after that i checked the file /var/www/php-fcgi-scripts/web2/.php-fcgi-starter and had the changes in it.

    You should not REMOVE it, but change the template to reflect your changes.
  3. drodrig

    drodrig New Member

    PHP changing session.save_path [SOLVED]

    Thank you Mark. That did the trick.
  4. RavanH

    RavanH New Member

    Hmmm... this does not work for sites using PHP-FPM :(
  5. drodrig

    drodrig New Member

    Try editing your fpm/php.ini file.

    I think php-fpm is not like php-cgi, and it doesn't use the command-line switches (could be wrong). Anyway, try adding these lines in /etc/php5/fpm/php.ini, or wherever your fpm php.ini file lives, under your [Session] section (remove any conflicting lines, of course):

    1411 ; Handler used to store/retrieve data.
    1412 ;
    1414 session.save_handler = memcache
    1415 session.save_path = "tcp://localhost:11211"

    This makes the change global. It works for me.
  6. RavanH

    RavanH New Member

    Hi drodrig, yes I tried that to start with but after checking via phpinfo on one of the sites, only the session.save_handler changed but not the session.save_path. That one remains set to the sites root path which worries me for I'm not sure if this will break session storage.

    Maybe it's due to the fact I'm using php_memcached instead of php_memcache module?
  7. drodrig

    drodrig New Member

    Hmm. I just checked using phpinfo() and both variables are set correctly. I'm by no means a PHP/FPM expert, but I would assume one of the following:

    * Your save_path entry in php.ini has an error in it so PHP is not applying it.
    * There is another save_path entry, either in the main php.ini file, or another config file (did you look in the pool.d folder (/etc/php5/fpm/pool.d on my server)? This folder can house php settings for individual websites. You could also do a 'grep -r save_path /etc/php5/fpm/* /etc/nginx/*'
    * The computer gods are angry at you. Sorry, I can't help with that :)
  8. RavanH

    RavanH New Member

    I thought the same and after searching the internet, I found that mod_memcacheD needs session.save_path = "localhost:11211" without the tcp protocol. Tried that, still no changes :( Then tried adding the rule to /etc/php5/mods-available/memcached.ini but still nothing...

    Turns out ISPConfig3 creates files like /etc/php5/fpm/pool.d/web1.conf where I found this rule:
    php_admin_value[session.save_path] = /var/www/clients/client0/web1/tmp
    And indeed, modifying that, finally changed the session_path !

    Problem is of course that this file is controlled by ISPConfig :(

    Is there any setting in ISPConfig that I need to change to prevent it from reverting to its old value?
  9. drodrig

    drodrig New Member

    There is a file (assuming your ISPConfig install is similar to mine):


    I suspect this might be the template file that ISPConfig uses to generate the .conf files in the pool.d directory. Perhaps you can add/change what you need to in this file. I'm not sure how ISPConfig will react -- will it update all virtual host conf files in your pool.d directory, or just new ones, or something in between. You'll need to test.
  10. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    You should copy the file to the conf-custom directory. The files inside conf will be overwritten on ISPConfig update.

    New pool files will be written when a web is added or edited, not when the pool file is changed.
    You can use the tools -> resync function to rewrite all pool files, though.
  11. RavanH

    RavanH New Member

    I tried configuring within the ISPConfig admin panel under the first site's config Additional PHP.INI Directives the line
    session.save_path = localhost:11211
    which did result in an extra line added to the /etc/php5/fpm/pool.d/web1.conf file:
    php_admin_value[session.save_path] = localhost:11211
    but it did not replace the old value nor did it result in a change in the actual php config. So setting this per site is not an option either :(

    YES! That did the trick. Had to resave the config for each existing site in the ISPConfig admin panel before changes took but it does indeed work :)

    Question: is it wise to change this file? And if not, is there a better/safer way?
  12. RavanH

    RavanH New Member

    Excellent! Crossing post answered my additional question. Thanks Croydon :)
    Last edited: Nov 17, 2013

Share This Page