Translate: 
EnglishFrenchGermanItalianPolishPortugueseRussianSpanish

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:

unzip realpath_turbo_1.2.zip
cd realpath_turbo
phpize
./configure
make
cp modules/turbo_realpath.so /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
enable=turbo_realpath.so
; 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.

Tags:

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/site.com/htdocs/sites/all/modules/ctools/includes/stylizer.theme.inc"]=> array(4) { ["key"]=> int(6167984749679351808) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/site.com/htdocs/sites/all/modules/ctools/includes/stylizer.theme.inc” ["expires"]=> int(1329480352) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/custom/zvuk_site/templates/st9.css"]=> array(4) { ["key"]=> int(4306855681017006080) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/site.com/htdocs/sites/all/modules/custom/zvuk_site/templates/st9.css” ["expires"]=> int(1329480352) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/views/transliteration/data/x82.php"]=> array(4) { ["key"]=> int(-3715418271708317696) ["is_dir"]=> bool(false) ["realpath"]=> string(86) “/var/www/vhosts/site.com/htdocs/sites/all/modules/views/transliteration/data/x82.php” ["expires"]=> int(1329480352) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/colorbox/styles/default/images/controls.png"]=> array(4) { ["key"]=> int(-369563009685011456) ["is_dir"]=> bool(false) ["realpath"]=> string(95) “/var/www/vhosts/site.com/htdocs/sites/all/modules/colorbox/styles/default/images/controls.png” ["expires"]=> int(1329480352) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/ubercart/shipping/uc_flatrate/uc_flatrate.admin.inc"]=> array(4) { ["key"]=> int(5824355701186042880) ["is_dir"]=> bool(false) ["realpath"]=> string(103) “/var/www/vhosts/site.com/htdocs/sites/all/modules/ubercart/shipping/uc_flatrate/uc_flatrate.admin.inc” ["expires"]=> int(1329480352) } ["/var/www/vhosts/site.com/htdocs/sites/all/modu...

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

    int(121533) array(891) { ["/var/www/vhosts/site.com/htdocs/modules/comment/comment.module"]=> array(4) { ["key"]=> int(6032762711705954304) ["is_dir"]=> bool(false) ["realpath"]=> string(64) “/var/www/vhosts/site.com/htdocs/modules/comment/comment.module” ["expires"]=> int(1329480724) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/imagecache_actions/customactions/imagecache_customactions.install"]=> array(4) { ["key"]=> int(2969938442673112066) ["is_dir"]=> bool(false) ["realpath"]=> string(117) “/var/www/vhosts/site.com/htdocs/sites/all/modules/imagecache_actions/customactions/imagecache_customactions.install” ["expires"]=> int(1329480754) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/metatag/metatag_opengraph/metatag_opengraph.module"]=> array(4) { ["key"]=> int(-8153450159225532413) ["is_dir"]=> bool(false) ["realpath"]=> string(102) “/var/www/vhosts/site.com/htdocs/sites/all/modules/metatag/metatag_opengraph/metatag_opengraph.module” ["expires"]=> int(1329480724) } ["/var/www/vhosts/site.com/htdocs/sites/all/modules/geolocation/modules/geolocation_googlemaps"]=> array(4) { ["key"]=> int(-2400054326342806524) ["is_dir"]=> bool(true) ["realpath"]=> string(94) “/var/www/vhosts/site.com/htdocs/sites/all/modules/geolocation/modules/geolocation_googlemaps” ["expires"]=> int(1329480724) } ["/var/www/vhosts/site.com/htdocs/includes/entity.inc"]=> array(4) { ["key"]=> int(-3304157662778662908) ["is_dir"]=> bool(false) ["realpath"]=> string(53) “/var/www/vhosts/site.com/htdocs/includes/entity.inc” ["expires"]=> int(1329480724) } ["/var/www/vhosts/site.com/htdocs/modules/system/system.install"]=> array(4)

  6. anybodywise says:

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

    var_dump(realpath_cache_size());
    var_dump(realpath_cache_get());

  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