How to set include_path for all websites (php.ini)?

Discussion in 'General' started by markusA, Nov 10, 2019.

  1. markusA

    markusA New Member

    Hi.
    I've just recently installed ISPConfig 3.1 on a debian 10 server running nginx.
    I figured out that I can set specific directives for individual sites by using ISPConfig control panel. But how can I add the private folder to the PHP include_path for each site as a base config?
    It should be doable in php.ini, but what is the proper syntax to include the private directory from each web root?
    When I set up my web pages, I only have a single file in the public_html directory, everything else is located in the private directory. I'd like to do my includes without risking accidentally revealing any information about the directory structure.
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Do you mean what ISPConfig Manual discusses in chapter 4.6.3.3 Protected Folders?
    In ISPConfig Panel, it is in Sites tab on the left pane under Web Access.
     
  3. markusA

    markusA New Member

    I must have been unclear in my original question, it doesn't have anything to do with password protected folders.
    When you set up a new website/domain, a home directory is created. Public_html or "web" (as it's called in the current setup of the server), is a folder in your home directory. The web folder is accessible by http. There is another folder in the home directory called "private", this folder is not accessible by http.
    By housing your php files in the private folder, you reduce the risk of accidental exposure to the outside world.
    By adding the private folder path to include_path, you don't have to use canonical paths (or relative paths) to include files from that folder. I can add the path to the custom php.ini settings found under the options tab, but that only works for individual domains.
    I'm looking for a way to always add the private folder to the include_path for all domains.
    It should be doable by editing the default php.ini file, but I don't know the correct syntax for referencing the "home" directory of the domains. The parent folder of "web". The php documentation mentions using ${home} but I haven't been able to find an example, and I don't know exactly how it works, so I'm flying blind here.
    There might be some alternative way to accomplish this in ISPConfig as well, I just don't know if there is?
    So, I'm asking for either a way to do this directly in ISPConfig (if possible) or the correct syntax for doing this in php.ini. There might be some other option that I haven't considered as well?
     
  4. Jesse Norell

    Jesse Norell Well-Known Member

    One option is to call set_include_path() from your single in "public_html" (which is actually called "web" in ISPConfig systems). Untested, but try:
    Code:
    set_include_path( get_include_path() . PATH_SEPARATOR . dirname ( __DIR__ ) . '/private' );
    Another is to specify in a .user.ini file.

    And the last option is probably what you really had in mind, you can edit the template(s) which ISPConfig uses to write the php config for each website. Which templates to edit varies with which php version you use. You should not use mod_php, so we'll ignore that. For php-fpm, copy /usr/local/ispconfig/server/conf/php_fpm_pool.conf.master to /usr/local/ispconfig/server/conf-custom/php_fpm_pool.conf.master and modify that (refer to the open_basedir line for an example of php_admin_value use, and any of the many lines referencing the 'document_root' variable for how to specify the correct path). It looks like 'php-fcgi-starter.master' is the template name for fastcgi mode.

    Note that when you create a conf-custom file like that, it is your responsibility to check for upstream changes to the original template whenever you upgrade ISPConfig, as there is (currently) nothing in place to compare your original to the version you're updating to.
     
    Steini86 likes this.

Share This Page