I need to host a php based website on IIS and I have come across some strange behaviour of .php files.
When I try to open index.php, I get the white screen of death. There are no error logs (I turned them On). I thought, that there is maybe an error in my code, althought it worked on Xampp, but neverthless I tried some simple code:
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>
I opened x.x.x.x/hello.php and got a white screen.
This could be caused by many problems, so I started testing them and this is where it got strange, so:
To the same directory I placed hello.html with the same content, but instead of the php part there is <p>Hello world</p>
. When I try to open x.x.x.x/hello.html it works and there is Hello world text displayed.
So I thought that there is problem with the .php part. I placed phpinfo.php with <?php phpinfo(); ?>
to inetpub/wwwroot. I opened localhost/phpinfo.php and it loaded all php info content.
Then I copied the hello.php to inetpub/wwwroot and opened localhost/hello.php and it worked, the browser displayed Hello world!
In short. In inetpub/wwwroot .php files work correctly and I am able to run them in browser. In any other directory of my Sites I get a white screen. But only with .php files. Html files runs normally.
So, I am really confused with this strange behaviour. I am new to the IIS, so I may have overlooked something, but right now I am stuck and I don't know what to do. Although I am able to run the website on inetpub/wwwroot, this is not the solution I am looking for.
Thank You for all the help.