How to share PHP libraries between sites not owned by the same customer

  • Hi

    I want to install a PHP library for multiple domains.

    For this I wanted to create and use a new domain in i-Mscp.

    I can configure the open-basedir with the listener.

    An include_once () results in the error "failed to open stream: Permission denied in ..."

    This is logical because the files belong to different users.

    What do I have for options with i-MSCP?

    i-MSCP 1.5.3 (2018120800)

    Debian 9

  • Good morning,

    Unless domain1 and domain2 are owned by the same customer, you cannot access files from each to others. This is due to the open_basedir restrictions.

    The solution is to install the shared library somewhere else, such as in the /usr/local/lib/php directory (you need to create that directory), and through relevant i-MSCP listener file, change the open_basedir parameter for all domains to add that directory. For best use, you should also add that path to the include_path (always through the listener file).

    Assuming that you're using latest i-MSCP version, you can use the following i-MSCP listener file:…

    Basically put, the %configOptions hash from the i-MSCP listener file should looks as follows:

    1. my %configOptions = (
    2. '*' => {
    3. 'open_basedir' => '{HOME_DIR}/:/usr/local/lib/php/:{PEAR_DIR}/:/dev/random:/dev/urandom',
    4. 'include_path' => '.:{PEAR_DIR}:/usr/local/lib/php/'
    5. }
    6. );

    The listener file need to be copied in the /etc/imscp/listeners.d directory. Once you have edited the configuration part of the listener file, you need trigger a i-MSCP reconfiguration, else, the changes won't be taken into effect: perl /var/www/imscp/engine/setup/imscp-reconfigure -danv.

    BTW: Don't forget that the listener file requires either FPM (recommended) or Fcgid.


  • Nuxwin

    Added the Label question (answered)
  • Nuxwin

    Changed the title of the thread from “Access via PHP from domain 1 to a file at domain 2” to “How to share PHP libraries between sites not owned by the same customer”.
  • Thread closed.


  • Nuxwin

    Closed the thread.