« Previous Next »

Answered Thread: PHP realpath() problem

Last post 12-03-2009 5:56 AM by _CallMeLaNN_. 10 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (11 items)

Sort Posts:

  • 12-16-2008, 5:48 PM

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    PHP realpath() problem

    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!

  • 12-16-2008, 5:52 PM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

    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.

  • 12-16-2008, 7:28 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: PHP realpath() problem

    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
    Senior Software Design Engineer
    IIS Core Server
  • 12-16-2008, 7:54 PM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

    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.

  • 12-16-2008, 8:02 PM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

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

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

  • 12-16-2008, 8:35 PM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

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

  • 12-16-2008, 8:56 PM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

    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!

  • 12-17-2008, 7:33 AM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Answered Re: PHP realpath() problem

    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.

     

  • 01-28-2009, 7:10 AM In reply to

    • huotg01
    • Not Ranked
    • Joined on 01-28-2009, 12:08 PM
    • Posts 1

    Re: PHP realpath() problem

    Good job isolating the problem.

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

    Thanks

    Gaston

  • 01-28-2009, 8:00 AM In reply to

    • david.s
    • Not Ranked
    • Joined on 12-16-2008, 9:05 PM
    • Posts 8

    Re: PHP realpath() problem

    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

  • 12-03-2009, 5:56 AM In reply to

    Re: PHP realpath() problem

    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

Page 1 of 1 (11 items)
Microsoft Communities