Warning: is_file(): open_basedir restriction in effect.

  • Hello,


    I have a problem caused by the open_basedir restriction that I cannot seem to solve. My website's structure is as follows:

    Code
    root
    ├─ app
    |  └─ PHP files that are `require`d by `index.php`
    ├─ public [DOCUMENT ROOT]
    |  └─ index.php

    Now, as I mention above, I require files from index.php that are located in /root/app. However, since the document root is at /root/public, I cannot do this because of the restriction that is in place. With the current setting for open_basedir I can only access files in the document root and in some other directory.


    Note that this structure is quite common, and so I think it is strange I cannot allow for this. Exposing the PHP files to the internet might pose a security risk.


    P.S.: Funnily, the open_basedir was unset initially, completely removing the restriction. However, the PHP version was 7.3, and I needed PHP 8. So sadly when updating the PHP version I could not leave the open_basedir setting unset.

  • Zur hilfreichsten Antwort springen
  • While I don't use Netcup's web hosting offering – what prevents you from simply moving the app folder below the public folder?

    VServer IOPS Comparison Sheet: https://docs.google.com/spreadsheets/d/1w38zM0Bwbd4VdDCQoi1buo2I-zpwg8e0wVzFGSPh3iE/edit?usp=sharing

    • Hilfreichste Antwort

    I guess we are talking about a netcup Webhosting offering here. You should change the open_basedir setting. This can be done in the WCP (Plesk) PHP settings. There are two alternative open_basedir settings available. The one which is the default and very likely active in your case is the one with {DOCUMENT_ROOT...} in it. This will allow PHP access to files withing the document root and below plus some system paths. You should choose the other one with {WEBHOSTING_ROOT...} instead, which allows PHP access to the entire webspace. So this one should work with your software.

  • While I don't use Netcup's web hosting offering – what prevents you from simply moving the app folder below the public folder?

    Well, nothing. But I don't want to expose the app directory to the internet for no reason.

    I guess we are talking about a netcup Webhosting offering here. You should change the open_basedir setting. This can be done in the WCP (Plesk) PHP settings. There are two alternative open_basedir settings available. The one which is the default and very likely active in your case is the one with {DOCUMENT_ROOT...} in it. This will allow PHP access to files withing the document root and below plus some system paths. You should choose the other one with {WEBHOSTING_ROOT...} instead, which allows PHP access to the entire webspace. So this one should work with your software.

    Wow, thanks so much! I misinterpreted the meaning of {WEBHOSTING_ROOT} so I didn't think it would work. Many thanks!

  • xpple

    Hat einen Beitrag als hilfreichste Antwort ausgewählt.