logo-full-thumb

HELP: FreeBSD Jails PHP dirname WordPress

So, I am still building up my jail structure and the last few evenings I was testing the FreeBSD jail wrt. PHP, Apache22-mpm-itk and wordpress.

Things started to break when I redirected external traffic to the jail. It seemed that require_once(dirname(dirname(__FILE__))) . ‘/wp-load.php’; does not work from within the jail.

I decided to do a little test and testing reveals that in a stand alone configuration the dirnames behave exactly the same, in both the host and the jail. Printing the directive within WordPress (when loading the admin pages f.ex.) reveals a ‘.’ instead of the ‘/path’ . It is resolvable by adding a ‘.’ to the directive so that wp-admin/admin.php loads the ../wp-load.php file instead of ‘/path/to/wordpress/wp-load.php’. Though this sounds very sily todo.

Did someone else encounter this? I Do not want to change enforcement of the statfs to some other value since the defaults should be good enough (given the testsript).

Relevant details: the /usr/home where the public_html files live, are nullfs rw mounted from the host and are available in the jail. The jail does username/group lookups through Ldap, and can see the various users. Apache had been build with the ITK patches so that every host runs under his/her own user. I do not see obvious differences between the regular host and the jail, the only real difference is the internal/external addresses used in the vhost configuration, but that is kinda obvious to me.

Let me know :-)

7 thoughts on “HELP: FreeBSD Jails PHP dirname WordPress”

  1. My blog runs in a jail on a 8.2 system (default statfs setting). The PHP files are served directly from UFS, not via nullfs (nullfs is used for the ezjail basejail handling and for distfiles/packages sharing between the jails on this machine, but the jail-specific data is on UFS). It’s a stock apache 2.2 (prefork-mpm) with php-suhosin. This works without problems or patches.

    phpMyAdmin which I have on a -current machine uses dirname (I just did a quick grep for it), and I have no problems with it. The PHP files are on ZFS, nullfs is only used like on the 8.2 machine, I use enforce_statfs=1 for the jail, and apache is a 2.2 with prefork-mpm.

    I suggest as a quick check to try to serve the PHP files directly from UFS/ZFS.

    1. Hi Alexander,

      Due to the setup i cannot use ufs directly, since the homedirs of users need to be accessible within more then one environment and we need to be compatible with the current setup (legacy heritage).

      I am setting up a test environment to test what you are describing, lets see how that results. Thanks for your time to reply to the post!!

  2. I don’t know what can be wrong with your setup. I am running PHP and Apache in jails with nullfs mount for many years without any problems.

    I tried your case with following example:

    It allways prints right resulting absolute path, no matter if it is in jail or in host, or if jail has nullfs mounted storage or not.
    I tried it in CLI and with Apache mpm_prefork.
    I tried PHP 5.3 and 5.2.

    Can you try it from CLI and can you try it with mpm_prefork instead of ITK?
    Also, can you try it with some simple test script instead of whole WordPress?

    1. Dear Miroslav,

      I have a basic test script which does exactly this from the same mounts and this seems to result on the desired behaviour. Sadly the installed wordpress doesnt seem to like it. I am testing in a seperated environment whether to see where this problem lies…

  3. hmm… comment don’t like PHP code, so my example again:

    echo dirname(dirname(__FILE__)) . ‘/wp-load.php’;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>