Search code examples
phpapacheopen-basedir

Is there any way I can bypass symlinks from php open_basedir?


I have configured open_basedir in Apache virtual host in Linux which is working fine.

<Directory /var/www/abc/public_html>
     php_admin_value open_basedir "/var/www/abc/public_html"
</Directory>

I am required to allow a single symlink which is located outside the specified basedir (/var/www/abc/public_html/files --> ../files).

Is there anyway to do that?


Solution

  • There is no way to bypass the open_basedir restriction, no. However, you could just include the additional symlink path to your open_basedir since it can accept more than just one path.

    open_basedir=/var/www/abc/public_html:/var/www/abc/files

    All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink.

    PHP Manual: open_basedir

    What you have to keep in mind is that open_basedir allows everything in a given path. So that means once access is granted to the path /var/www/abc/files, everything in that path like /var/www/abc/files/foo, /var/www/abc/files/bar, etc... is also allowed.