IIS 7 and Above
PHP realpath() problem
Last post Jan 07, 2010 05:04 PM by davidkassa
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
The following PHP code demonstrates the problem -
echo realpath( '.' );
echo realpath( '.' );
On IIS6 using php5isapi.dll this reports the correct path, eg -
On IIS7 with FastCgi using c:\php\php-cgi.exe this reports -
On IIS7 with php5isapi.dll this reports -
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!
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.
Dec 16, 2008 07:28 PM|anilr|LINK
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?
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.
Dec 16, 2008 08:02 PM|david.s|LINK
A simple write to a session variable worked fine, so not a permissions problem.
$_SESSION['myvar'] = 5;
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.
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!
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.
Jan 28, 2009 07:10 AM|huotg01|LINK
Good job isolating the problem.
For a "morron user", could you summarize what should be done.
Jan 28, 2009 08:00 AM|david.s|LINK
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
Dec 03, 2009 05:56 AM|_CallMeLaNN_|LINK
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?
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!