PHP realpath() problem [Answered]RSS

11 replies

Last post Jan 07, 2010 05:04 PM by davidkassa

  • PHP realpath() problem

    Dec 16, 2008 05:48 PM|david.s|LINK

    I've been trying to migrate a MediaWiki installation to a w2k8 IIS7 server and been encountering headaches. I've eventually tracked it to an issue with the PHP function realpath().

    The following PHP code demonstrates the problem -

    <?php
    echo realpath( '.' );
    ?>

    On IIS6 using php5isapi.dll this reports the correct path, eg -

    c:\inetpub\wwwroot

    On IIS7 with FastCgi using c:\php\php-cgi.exe this reports -

    c:\PHP

    On IIS7 with php5isapi.dll this reports -

     C:\Windows\System32\inetsrv

    Clearly the IIS7 responses are not what is wanted! Both servers are using PHP 5.6.8 and all MS updates. I've been unable to find any differences in php.ini settings that might make a difference, and no idea where to look in IIS7.

    Any help greatly appreciated!

    PHP fascgi

  • Re: PHP realpath() problem

    Dec 16, 2008 05:52 PM|david.s|LINK

    Just to add, I tried running the script from command line PHP on w2k8 and it responds correctly, so it's some issue within the IIS7 context.

  • Re: PHP realpath() problem

    Dec 16, 2008 07:28 PM|anilr|LINK

    Look at this thread regarding current working directory for php under fastcgi vs cgi - the ISAPI example you gave seems wierd, how can that work if you have 2 websites hosted in the same worker process and both receive requests at the same time?

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: PHP realpath() problem

    Dec 16, 2008 07:54 PM|david.s|LINK

    Thanks for the link, it seems to be the same problem, but I'm not 100% convinced of the reply. As noted above there's an entire page on setting up MediaWiki on IIS7 with fast-cgi, so it apparently is working fine for some!

    I also tried wordpress on another site and got the same problem, and I think both wordpress and mediawiki failing on IIS7 would be rather notable! There was though a further hint there's something else going on. A Joomla site on the server is working fine - but after I loaded it up, the test files with realpath() on other sites on the server reported the path to the Joomla site.

    So it appears there's something screwing up with session variables. Checking the c:\php\session folder the files are being created, but are all zero length. I'm no php programmer, but that doesn't seem right?

    re ISAPI, it's a brand new VPS so I swapped PHP handlers to see what happens.

  • Re: PHP realpath() problem

    Dec 16, 2008 08:02 PM|david.s|LINK

    A simple write to a session variable worked fine, so not a permissions problem.

     <?php
    $_SESSION['myvar'] = 5;
    echo $_SESSION['myvar'];
    ?>

  • Re: PHP realpath() problem

    Dec 16, 2008 08:35 PM|david.s|LINK

    Moving the sites off of wwwroot to a sub directory seems to solve the problem, but quite obviously this is not an ideal solution.

  • Re: PHP realpath() problem

    Dec 16, 2008 08:56 PM|david.s|LINK

    An additional note, I've confirmed this is not just a fast-cgi problem, it's also occurring with php5isapi.dll on IIS7.

    this was NOT a problem on my IIS6 setup. Either there's something odd about my setup or IIS7 is not compatible with running common PHP apps from website root folder.

    Please somebody tell me this is not so!

  • Re: PHP realpath() problem

    Dec 17, 2008 07:33 AM|david.s|LINK

    After much gnashing of teeth the solution has been found.

    The problem described does not occur if the account the website is running under has Read permission for the parent folder. If you have your sites setup under inetpub then this is already in place.

    I'm using DotNetPanel and it uses a different folder structure which does not have this permission, however it can easily be added through the DNP file manager, or of course it can be done via console.

     

    PHP FastCGI

  • Re: PHP realpath() problem

    Jan 28, 2009 07:10 AM|huotg01|LINK

    Good job isolating the problem.

    For a "morron user", could you summarize what should be done.

    Thanks

    Gaston

    PHP fascgi

  • Re: PHP realpath() problem

    Jan 28, 2009 08:00 AM|david.s|LINK

    Hi,

    I explained it a bit further on my blog - Migrating to a new IIS7 install from IIS6.

    Basically just make sure the folder above your website is readable by IIS7

  • Re: PHP realpath() problem

    Dec 03, 2009 05:56 AM|_CallMeLaNN_|LINK

    Hi,

    Can you tell me the specific account name? Which one.
    I know IIS in WinXp and Win2003 using different account that is ASPNET and NETWORKSERVICE but for IIS7 Win2008 what is the account you mean to solve the realpath() for php?

    Thanks

  • Re: PHP realpath() problem

    Jan 07, 2010 05:04 PM|davidkassa|LINK

     I just wanted to quote this text since it helped me after about a days worth of struggles.

    Thanks a ton!

     -------

    After much gnashing of teeth the solution has been found.

    The problem described does not occur if the account the website is running under has Read permission for the parent folder. If you have your sites setup under inetpub then this is already in place.

    I'm using DotNetPanel and it uses a different folder structure which does not have this permission, however it can easily be added through the DNP file manager, or of course it can be done via console.