PHP configuration

Discussion in 'Installation/Configuration' started by Bocki, Jul 17, 2018.

  1. Bocki

    Bocki New Member HowtoForge Supporter

    Hi everybody,
    I've got two ISPConfig hosts which got updated several times over time (both the base Debian system and ISPConfig), currently they are running an up to date Debian 9 and ISPConfig 3.1.12.
    I noticed now that the PHP configuration shows "strange" (i.e. old) entries in System - Server config - Web - PHP Settings:
    This does not match my running system at all: it uses PHP 7 (original Debian packages) with PHP-FPM, the referenced php5-directories do not exist (any more).
    All sites show in their respective configs "Fast-CGI" for PHP - which seems to be incorrect, too?
    Don't these settings get updated during updates of the system?
    Thanks in advance!
     
  2. Jesse Norell

    Jesse Norell Well-Known Member

    The old paths are probably in your ispconfig settings, saved in the database from your older versions.
    When you update major versions which change default php versions like debian 8 -> 9 you should update those settings, as they (unfortunately) are not tested or updated automatically. Is php working for you? Generally it's just cosmetic, ie. with an old name "php5" in the paths, but all files are created and work fine. (I've updated Debian 8 -> 9 and nothing removed the old directories for me.)

    This is from a recent clean install on Debian 9 under System > Server Config > {server} > Web > PHP Settings:
    Code:
    Apache php.ini path:  /etc/php/7.0/apache2/php.ini
    CGI php.ini path:  /etc/php/7.0/cgi/php.ini
    PHP-FPM init script:  php7.0-fpm
    PHP-FPM php.ini path:  /etc/php/7.0/fpm/php.ini
    PHP-FPM pool directory:  /etc/php/7.0/fpm/pool.d
    PHP-FPM start port:  9010
    PHP-FPM socket directory:  /var/lib/php7.0-fpm
    PHP open_basedir:  [website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom
    
    After you change that do a resync on all websites.

    There has been mention of ISPConfig creating and using it's own directory for those files specifically to avoid confusion like this, though I don't know if there's an actual rfe for it in the bug tracker.
     
    ahrasis likes this.
  3. ahrasis

    ahrasis Well-Known Member

    The settings are currently in the ISPCOnfig database that can be correctly rectified by editing in ISPCOnfig panel as suggested by @Jesse Norell above. I don't think that they have been moved to any file yet.

    And no, I don't think these settings get updated during system or ISPConfig updates.
     
  4. Bocki

    Bocki New Member HowtoForge Supporter

    Thanks for your replies!

    What are the settings in ISPConfig for when they are obviously not representing the system settings?

    I'll try correcting the settings and resyncing.

    Two additional questions to get everything right:
    When I set "Default PHP Handler" to "PHP-FPM" - will this be carried to all configured sites in which I did not explicitly chose a PHP mode? Or is this setting just for newly created sites?
    Currently for all configured sites the PHP mode shows "Fast-CGI" but actually PHP-FPM is used (I checked with phpinfo() in the sites). What will happen when I carry out the resync? Will the actually used PHP-FPM be set in the configuration or will I end up with sites using Fast-CGI?
     
  5. Jesse Norell

    Jesse Norell Well-Known Member

    no, each site has a mode set, so the old ones will have the old default, and new sites will have the new default selected.

    I don't know, I've never seen a mix-up like that. Back up first and try it. :) If fastcgi is selected and works for new sites, I'd guess you would end up with fastcgi on all of them after resync. You could update all sites to php-fpm first, then do the resync, and should be good.
     
  6. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    pro tip: the mode can be changed with a simple update-query on database if you plan to resync anyway... no need to go trough every single page, open phpmyadmin and if you can't guess where to look, better don't try ;) or ask someone who's not about to end the night ^^
     
    ahrasis likes this.
  7. Jesse Norell

    Jesse Norell Well-Known Member

    Right, if you open and save every domain, you will no longer need to resend. I did some sql updates for pp version in the past and I just changed one site manually and compared the database table (web_domain, I think) for that domain before and after, then built the sql update query based on that. I could maybe did the commands up from MySQL history if needed.
     
  8. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    1. Create / Update one site with the desired PHP config
    2. Update the config for other domains
    Code:
    UPDATE `web_domain` AS target INNER JOIN `web_domain` AS source ON source.`domain` = 'domainYouSetAsTemplate' SET target.`php` = source.`php`,  target.`php_fpm_use_socket` = source.`php_fpm_use_socket`,  target.`fastcgi_php_version` = source.`fastcgi_php_version`, target.`custom_php_ini` = source.`custom_php_ini`;
    
    3. Resync your webs

    However there can be issues regarding open basedir or some custom php settings, maybe but minor issue compared to go trough like 200 webs to set the php version :D
    just replace domainYouSetAsTemplate in the query with your example domain.
     
    Jesse Norell likes this.
  9. Bocki

    Bocki New Member HowtoForge Supporter

    Thanks again to all who answered!
    I've updated the settings in the database and resynced afterwards, everything works fine. Now the chosen PHP method works as expected, too.
     
    ztk.me likes this.

Share This Page