Reputation: 10037
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<TITLE></TITLE>
</HEAD>
<BODY>
<?php echo '<p>Hello World</p>'; ?>
</BODY>
</HTML>
When I run the above code in a browser, firefox renders it like this:
Hello World
'; ?>
I am doing my coding in Windows XP/IIS 5.1. I have PHP set up correctly because I have no problem running .php files. The problem, it seems to me, is that IIS can't render php code embedded inside html. Does anyone know how to fix this problem or should i switch to Apache?
edit: the file extension is .html
Upvotes: 2
Views: 4453
Reputation: 31
The same problem using windows 7 IIS and php can be solved by going to Start->Control_panel->Administrative_Tools->Internet_Information_Services_(IIS)_Manager. Then you have to select the connection, which has a problem, then double click "Handler mappings",
on the right side of the table you can see "Actions" panel, click on the "Add module mapping", in the "Request path" field you have to write "*.html" (without quotes), in the "Module" section choose "FastCgiModule", in the "Executable" section locate the path of php-cgi.exe file, in the "Name" section write let's say "html" (wihtout quotes),
then push the "Request Restrictions button", mark the "Invoke handler only if request is mapped to" and choose "File or folder" hit ok, hit ok one more time, click "Yes"
now your iis server should understand php script in *.html documents.
Upvotes: 3
Reputation: 159905
You need to tell IIS to run your .html
files through the PHP interpreter rather than serving them directly.
I'm not sure how one does that ... a little googling turned up this:
N.B. / Caveat emptor What follows is taken from the Microsoft Support site and the answer is for setting up IIS with Perl -- I believe that it should also work for PHP, or at least start you on the right track, but I haven't tested it as I don't have IIS.
Click Start, click Programs, click Administrative Tools, and then click Internet Information Services. Right-click a Web site that you want to enable PHP for, and then click Properties. Click the Home Directory tab. Click Configuration. Click Add. Type the following for Executable: full path to php.exe\php.exe %s %s Note The "%s %s" is case sensitive (for example, "%S %S" does not work). For Extension, type .html.
Note Make sure that the All Verbs option is selected for full functionality. Also, make sure that the Script Engine check box is selected. Click OK to return to the ISM. With the default scripts directory with IIS, the URL is the following: http:// Server Name/scripts/helloworld.html
Upvotes: 1