custom php settings

  • Hi,


    Can you recommend how to set custom php settings for a site in the php-fpm pool without them being overwritten when the user for example enables error logging or changes any of the other settings available. In this environment these values can't be set using the .htaccess file or on the apache level. Well at least I can't see how it is done.


    Best


    Siggi

  • Hi Siggi


    I think the pool is configured in here: /etc/php5/fpm/pool.d/$yourdomain.com.conf. The problem is that this file is rewritten when the customer changes mentioned setting. Check here: /etc/imscp/php-fpm/working. The file there is adjusted and then copied to the php5/fpm path. So if you adjust the template file, it will be reused. But the template could be recreated during imscp panel updates.


    For Apache2 there is /etc/apache2/imscp where you can put custom config stuff for each domain. Edits here will only work with mod_php. Probably such an include could make sense for php-fpm as well?

  • Hi,


    Yes that is the solution. Include per pool is possible in php-fpm, so I will just put it in the pool template. The include file does not even have to exists. So when needed I will created and the settings will be used. Excellent. Thank you @bytesplit


    Best


    Siggi

  • I want to confirm that this works great. All you need to do is add to the pool template /etc/imscp/php-fpm/parts/pool.conf something like

    Code
    1. include = /whateverpath/{POOL_NAME}.conf


    The file does need to exist, but say you want to add custom php_value you can create it and add to it whatever is needed.


    Best


    Siggi

  • @seinarsson


    Simple solution


    1. Edit the /etc/php5/fpm/php-fpm.conf and at bottom, add the following:

    PHP
    1. ; Custom configuration snippetinclude=/etc/php5/fpm/imscp_custom.conf


    2. Create the /etc/php5/fpm/imscp_custom.conf file

    Shell-Script
    1. # touch /etc/php5/fpm/imscp_custom.conf


    Then from now, to add or override PHP configuration parameter for a specific pool, just add in the /etc/php5/fpm/imscp_custom.conf file something like


    PHP
    1. [domain1.tld]
    2. php_admin_value[max_execution_time] = 60
    3. [domain2.tld]
    4. php_admin_value[max_execution_time] = 20


    It's just an idea. I'll test it. This allow you to create only one file for custom PHP snippets.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Re;


    The solution above only works for parameters which are not yet defined in the pool configuration file. Already defined parameters are not overridden.


    To resume if in the /etc/php5/fpm/pool.d/domain1.tld.conf file you already have:


    Code
    1. ...php_value[disable_functions] = php_value[disable_functions] = show_source,system,shell_exec,passthru,exec,phpinfo,shell,symlink,proc_open,popen...


    Adding the following in the /etc/php5/fpm/imscp_custom.conf file


    Code
    1. [domain1.tld]
    2. php_value[disable_functions] = php_value[disable_functions] = show_source,system,shell_exec,passthru,exec,shell,symlink,proc_open,popen


    Will not work (i.e. usage of phpinfo() function will be still disallowed).

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • I'll implement that.


    We can override any of the values as long they are defined first with php_value insteand of php_admin_value. I'll so provide custom file with predefined values but custom file, once installed will not be overriden ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Could this be possible like what we have for Apache? A imscp directory with one include file per domain/pool?


    Another question comes to mind: what sense has php_admin_value? If it's there to not be overwritten, assigning it as php_value also means it can be overwritten by customer php's? That would mean a security threat then...


    I will check PHP docs

  • Hello ;


    Any parameter set with php_admin_value cannot be overridden using the ini_set() function while any parameter set with php_value can ;) This is so difficult provide default restricted values ( set with php_admin_value ) in pool configuration files because we cannot overridden them in local pool configuration file. As I see, we must provide local local pool configuration file for each pool which come with restricted parameters ( set with php_admin_value). After, if the admin decide to change them, it's not our problem. Once installed, the local pool configuration file must not be overridden by the i-mscp installer.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206