Running PHP on NFS: version 1.2 of turbo_realpath extension

I proudly present new version of my PHP extension which solves the performance problems with PHP application and NFS storage. This version adds support for safe_mode = on setting.

How to install turbo_realpath?

Please note that 1.2 version of turbo_realpath extension is not compatible with PHP 5.4. Please download the latest 1.3 version which solves this problem (thanks Sebastian Siemssen for reporting and fixing that issue).

You can download the latest version of this extension from here (1.3 version compatible with PHP 5.4+) or older (1.2 version) from this link.

In order to use this extension, you have to compile it first:

cd realpath_turbo
cp modules/ /usr/lib/php/modules

Please, remember to change /usr/lib/php/modules to the path used by your PHP installation.

Next, you have to configure this PHP extension in php.ini file, like so:

; you have to load the extension first
; set this to 1 in order to disable dangerous PHP functions (link,symlink), or set to 0 in order to ignore potential security issues
realpath_cache_security = 1
; if you want, you can enable safe_mode, in order to do so, you have to switch off
; standard open_basedir setting...
open_basedir = off
; and then switch on custom realpath_cache_open_basedir setting,
; (remember, safe mode is not required by realpath_turbo extension, 
; you can safely ignore these settings if you want)
real_path_cache_safe_mode = on
; then copy the value of open_basedir into realpath_cache_basedir parameter
realpath_cache_basedir = /var/www/html/drupal
; and finally DISABLE the open_basedir setting,
; it will be changed automatically to the value of a realpath_cache_basedir setting.
; open_basedir=""

As you can see, in order to use this extension, you have to move the value of open_basedir setting into realpath_cache_basedir and then disable open_basedir itself. After this, PHP will reenable open_basedir restrictions automatically.


8 Responses to “Running PHP on NFS: version 1.2 of turbo_realpath extension”

  1. ux says:

    could this extension run on php4?

  2. Artur Graniszewski says:

    It should, but some changes may be necessary to do so. Unfortunately I do not have a PHP4 server to check this case. But if you’ll try to compile my extension on such configuration, I would gladly help you with rewriting the extension.

  3. anybodywise says:

    Why are static files getting cached – e.g. images and CSS? I tested it on Drupal, WordPress and phpbb – the same. Also isn’t caching both / and /./ a bug?

  4. Artur Graniszewski says:

    Hi anybodywise,

    can you tell me more about your problems? Static files may be cached by your server configuration (forward proxy, mod_cache in Apache, etc), or your ISP.

  5. anybodywise says:

    I use this to check cache contents:

    This is what I get when I activate realpath_cache_basedir (I have realpath_cache_size=1M and it is completely used – see the int(1048571) and take a look at .png, .css files):

    int(1048571) array(7235) { ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(6167984749679351808) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/” ["expires"]=> int(1329480352) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(4306855681017006080) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/” ["expires"]=> int(1329480352) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(-3715418271708317696) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/” ["expires"]=> int(1329480352) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(-369563009685011456) ["is_dir"]=> bool(false) ["realpath"]=> string(95) “/var/www/vhosts/” ["expires"]=> int(1329480352) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(5824355701186042880) ["is_dir"]=> bool(false) ["realpath"]=> string(103) “/var/www/vhosts/” ["expires"]=> int(1329480352) } ["/var/www/vhosts/

    And this when open_basedir is disabled (only 123 KB are used and no static file here):

    int(121533) array(891) { ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(6032762711705954304) ["is_dir"]=> bool(false) ["realpath"]=> string(64) “/var/www/vhosts/” ["expires"]=> int(1329480724) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(2969938442673112066) ["is_dir"]=> bool(false) ["realpath"]=> string(117) “/var/www/vhosts/” ["expires"]=> int(1329480754) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(-8153450159225532413) ["is_dir"]=> bool(false) ["realpath"]=> string(102) “/var/www/vhosts/” ["expires"]=> int(1329480724) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(-2400054326342806524) ["is_dir"]=> bool(true) ["realpath"]=> string(94) “/var/www/vhosts/” ["expires"]=> int(1329480724) } ["/var/www/vhosts/"]=> array(4) { ["key"]=> int(-3304157662778662908) ["is_dir"]=> bool(false) ["realpath"]=> string(53) “/var/www/vhosts/” ["expires"]=> int(1329480724) } ["/var/www/vhosts/"]=> array(4)

  6. anybodywise says:

    I use this to check cache contents (it was cut off by WordPress parser):


  7. anybodywise says:

    Hello again,
    do you have some idea about this?

  8. Artur Graniszewski says:

    Are you sure that PHP is not accessing these files in any way? It’s enough to use file_exists() function to check the existance of a PNG file (in image gallery for example) to cache the path.

Leave a Reply