Solved

PHP IIS Blank page

Posted on 2011-03-11
46
2,554 Views
Last Modified: 2012-05-11
Hi,

Have installed PHP 5.3.5 on IIS 6 Windows Server 2003 standard x64 edition via manual install per the PHP documentation.

Command line php -i returns information, but file php.htm containing:
<title>
PHP Test
</title>
<?php
phpinfo();
?>

returns blank page, though the title appears

What am I doing wrong?

Thanks!
php.ini
0
Comment
Question by:mitcht
  • 17
  • 13
  • 6
  • +2
46 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 200 total points
Comment Utility
You need to name it php.php, not php.htm.  It will work then if PHP is configured correctly on IIS.
0
 
LVL 30

Assisted Solution

by:Brad Howe
Brad Howe earned 100 total points
Comment Utility
Your extention is wrong. That is going through the html processor

change the file extention to test.php.

Cheers,
Hades666
0
 

Author Comment

by:mitcht
Comment Utility
Changed file to php.php.  I get a 'windows cannot open the file' error.  IIS mis-configured?

Thanks for the responses!
0
 
LVL 10

Assisted Solution

by:aboo_s
aboo_s earned 100 total points
Comment Utility
Either rename to test.php or add this to your .htaccess file in the directory where you are running this file

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

If you do not have this file in your current directory or in root directory you can create one with notepad or maybe dreamweaver .

Hopes this helpes!
0
 
LVL 30

Expert Comment

by:Brad Howe
Comment Utility
In IIS Manager, did you config the PHP extention mapping?

Specifically "Manually Configure the FastCGI Extension to Work with PHP"
http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

Cheers,
Hades666
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I have to recommend that you do not remove the HTML handler, just add the PHP handler.  In addition, I don't believe that ".htaccess" will do anything in a stock IIS6 installation.
0
 
LVL 30

Expert Comment

by:Brad Howe
Comment Utility
agreed, I stayed away from the .htacess comment.

Follow the FastCGI manual setup for IIS6/5.1 from learn IIS/PHP and let us know if it works.

We can troubleshoot more after that.

cheers,
Hades666
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Here are the instructions from PHP.net: http://www.php.net/manual/en/install.windows.iis6.php
0
 
LVL 29

Assisted Solution

by:Randy Downs
Randy Downs earned 100 total points
Comment Utility
Even php.htm should return the title. I suggest adding some text & you'll see that file. As others have pointed out it needs to end in .php for dynamic information to be displayed.

IIS needs to be setup to process php. Have you installed php? http://www.php.net/manual/en/install.windows.installer.msi.php

By default the lastest php will try to setup as FastCGI so your IIS should be set to handle it.

Hope this helps.
0
 

Author Comment

by:mitcht
Comment Utility
Yes, I did config Fast CGI.  Here's my notes:

http://us3.php.net/manual/en/install.windows.iis6.php

fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0

http://www.iis.net/download/fastcgi

x64 fast CGI installed

cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" ^
-extension:php -path:"D:\PHP\php-cgi.exe"

cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^
-EnvironmentVars:PHPRC:"D:\PHP\"

IUSR_ENGCM-SJ1-VM14

icacls D:\inetpub\wwroot\upload /grant IUSR_ENGCM-SJ1-VM14:(OI)(CI)(M)
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Have you restarted the server?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Actually, have you rebooted the computer.  I've found a number of things don't seem to start working in IIS unless you do.
0
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
I think you have to set IIS to work as 32 bit for php.

Go into the application pool for the website, right click, Advanced Settings, and then change Enable 32-bit Applications to true.
0
 

Author Comment

by:mitcht
Comment Utility
I did: cscript D:\inetpub\AdminScripts\adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1

Rebooted.  No joy.
0
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
Can you see your test page at http://localhost/php.htm ? Or anything on localhost?
0
 

Author Comment

by:mitcht
Comment Utility
I can see the default under construction page.

I created a php.htm page in the directory, which I can see as http://localhost/php.htm - no php code works, only html.

http://localhost/php.php returns a 404 error, but the file is there
0
 
LVL 10

Expert Comment

by:aboo_s
Comment Utility
Ok if the file is there then you will see it's content even if you don't have php scripting enabled!

So if you are getting 404 on this file while other files can be seen well this means you mistyped something or maybe the file is not there, i can't find any other explanation!
0
 
LVL 30

Expert Comment

by:Brad Howe
Comment Utility
Hi,

PHP is x86 and you are running your app in a x64 work process.

To have IIS server PHP files the extention needs to be .php. This is how FastCGI mapping works.

When troubleshooting, make Internet Explorer give a useful error message to work with. You can do this by clicking Tools | Internet Options | Advanced and then unchecking  "Show friendly HTTP error messages".

I bet you are getting the % not a vaild win32 application error.

In order to configure IIS to run in 32-bit mode you need to execute the following command :

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1


Now, if you have an HTML coded file with PHP code embedded, it will not get exectuted.

Follow the setup here.

Specifically "Manually Configure the FastCGI Extension to Work with PHP"
http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

Windows Server 2003 SP1 enables WOW64 compatibility for 32-bit Web applications in IIS 6.0
http://support.microsoft.com/?id=895976

Cheers,
Hades666
0
 

Author Comment

by:mitcht
Comment Utility
php.php and php.htm files are in the same dir (D:\inetpub\wwwroot).

I can type in D:\inetpub\wwwroot\php.php and see the code, so it's there.  I even mistyped it to verify that IE would display an error.  Repeated w/D:\inetpub\wwwroot\php.htm, and that displayed OK (still no php display, though)

I've configured 32 bit apps in Win 64 and FastCGI, please see my previous posts.

Arg.
0
 
LVL 30

Expert Comment

by:Brad Howe
Comment Utility
D:\inetpub\wwwroot\php.php is local through a browser. That is not processed through IIS.

D:\inetpub\wwwroot\php.htm is local through a browser. The browser sees htm and doesn't call the php compiler.


As mentioned above, re-run through the manual configuration. Show errors and see the true error.

Cheers,
Hades666
0
 
LVL 29

Expert Comment

by:Randy Downs
Comment Utility
You might want to re-install php. It clearly is not working. Likewise you could remove IIS & install it again.
0
 

Author Comment

by:mitcht
Comment Utility
Hades666: Same thing when I call files as localhost/php.hem or localhost/php.php

Reinstall not indicated.  PHP working @ command line, it's a config issue.

Same thing if friendlr error messages turned on or off

And when I  juse enter localhost, I get the under construction page, so that should confirm the dir IS points to.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
If you can see the 'php.htm' thru "http://localhost/php.htm" in your browser, then it is accessing the correct directory.  If the "under construction page" is yours and you put it in the same directory, same thing.  Does PHP run from the command line In that directory?

You have to have set IIS permissions in that directory to allow scripts and execute permissions to allow scripts.  This is in addition to installing the PHP handler.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:aboo_s
Comment Utility
I have this test for you to make, I'm thinking maybe something is wrong,
Please go to your root directory and alter some text in your underconstruction page
then run it through IIS server see if iti is the same page!
0
 

Author Comment

by:mitcht
Comment Utility
All, the server is down for the wknd.  Will get back on this Monday.

Thanks for all your attention, I'll get back w/updates!
0
 

Author Comment

by:mitcht
Comment Utility
OK, back to it.

PHP runs from the command line in D:\inetpub\wwroot

I added text the underconstruction page, and it appears

In IE, entering http://localhost/php.htm shows the html page
entering http://localhost/php.php returns a 404 error

When I roght click on the default web site, and click properties > Home Directory > Configuration, I don't see .php i nthe application extention list.  When I add d:\php\php-cgi.exe and restart IIS, it does not appear in the list when I check to see if it's still there. ???
0
 
LVL 30

Expert Comment

by:Brad Howe
Comment Utility
Hi, as mentioned before. The extention needs to be php.

As well both instructions davebaldwin and I provided explain what you need to do.

If the mike type is not listed IIS will never serve php coded files.

Good luck.
Hades666
0
 

Author Comment

by:mitcht
Comment Utility
OK, let me go through your posts and verify that everything is in order:

File extension is test.php

 "Manually Configure the FastCGI Extension to Work with PHP" - verified
http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

Server restarted
Can see underconstruction page w/modified text
.php extension in default web site configured to c:\WINDOWS\SysWOW64\inetsrv\fcgiext.dll

'Show friendly HTTP error messages checked in IE

Running php -i from command line in d:\inetpub\wwroot returns php settings



0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Now put this file in your web root as 'phpinfo.php' and access it thru the web server with your browser.  Something like "http://www.mywebserver.com/phpinfo.php" or "http://localhost/phpinfo.php".  It should show you the same info as php -i from command line but in a web page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>PHP Check</title>
</head>
<body>
<p>PHP Check</p>
<?php phpinfo() ?>

</body>
</html>

Open in new window

0
 
LVL 10

Expert Comment

by:aboo_s
Comment Utility
DaveBaldwin, I think he will not see the page at all, I checked with him for this before!
What I think is that for some reason the server is blocking php files or hiding them, this could be due to a rule a ristriction or something. Anyway please try running your php.html again after adding this to your
.htaccess file:
AddType application/x-httpd-php .php .htm .html .asp
if you don't have one in your root create it.
Please just give it a shot I think it might work, and if it does we'll know how to go on from there!
0
 

Author Comment

by:mitcht
Comment Utility
Thanks for sticking with this guys.

aboo_s, I created the htaccess file in D:\inetpub\wwroot  A copy is attached

DaveBaldwin, I then placed your html in D:\inetpub\wwroot, fired up IE, entered http://localhost/phpinfo.php, and got a 404 error.

Arg!
0
 
LVL 10

Expert Comment

by:aboo_s
Comment Utility
Ok, I understand,

Now I want you to please go to the following link and see the steps in there and make sure you have them all configured the right way on your server:

http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

Although it is very strange because even if you are not configured to run php you still can see the files which in your case you do not, but since we are talking about a strange situation it won't hurt to double check that everything is in it's place!
0
 
LVL 10

Expert Comment

by:aboo_s
Comment Utility
Furthur more,

can you follow the 404 error in your IIS log to determine what kind exactly it is, if it is 404.3 it means
("404.3 - MIME map policy prevents this request.")
the server is restricting the file not that it doesn't see it, and if that is the case you have to go over configs again!

You can try removing all restrictions for a little whil and then run php to see it, to know what you are dealing with exacatly.
 to remove restrictions follow this thread that I copied:

"IIS6 doesn't serve unregistered MIME types to improve security. To
add new types, right-click the server(computer icon) in IIS6 mmc and
open its properties. Click MIME Types. Also, you can only allow
specific MIMEs on specific sites or vdirs - sites/vdirs' HTTP Header
tab->MIME types.

For any types don't have a definite MIME type string, you can simply
set them as the default value: application/octet-stream

Furthermore, adding (*) wildcard to disable MIME restriction on all
file types is supported but this is not a recommended action. "





0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
This question has some interesting things: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Installation/Q_26891834.html  Try:

php-cgi.exe D:\inetpub\wwwroot\php.php > D:\inetpub\wwwroot\phpinfo.html

Then see if the "phpinfo.html" shows any errors.  You can post it here to let us look at it too.
0
 

Author Comment

by:mitcht
Comment Utility
Hmmm...

Have a look.
phpinfo.html
php-err1.png
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
In your "phpinfo()", you have the same error as in the other question.  Try what they did and see if it helps your situation.  http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Installation/Q_26891834.html
0
 

Author Comment

by:mitcht
Comment Utility
That got rid of the 500 eror.  Attached is the html result  phpinfo.html
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
That's good.  Can you access PHP pages with your browser now or are you still getting an error from the server?
0
 

Author Comment

by:mitcht
Comment Utility
Entering either localhost/phpinfo.php or D:\inetpub\wwwroot\phpinfo.php in IE returns a 404 error
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
"D:\inetpub\wwwroot\phpinfo.php" shouldn't work at all.  "http://localhost/php.php" should be the original file unless you have changed the name.  You have to run it thru the server for the PHP to execute if PHP is installed properly.
0
 

Author Comment

by:mitcht
Comment Utility
I entered the code you suggested on the 15th, and stored the file as D:\inetpub\wwwroot\phpinfo.php
0
 

Author Comment

by:mitcht
Comment Utility
excuse me d:\inetpub\wwroot
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 200 total points
Comment Utility
Ok, I didn't realize that.  So I'm still puzzled.
0
 

Author Comment

by:mitcht
Comment Utility
OK, I got another server up, so am giving up on this.  I'll divy up points to those who were most helpful
0
 

Author Closing Comment

by:mitcht
Comment Utility
Never got the server up.  I got another server to due duty on this.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Sorry we couldn't help you more.  Sounds like you tried everything we know.  Thanks for the points.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now