PHP on IIS. Getting includes to parse PHP...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

PHP on IIS. Getting includes to parse PHP...

Post by network23 »

I don't have particulars right now, but I wanted to ask this question ASAP in hopes of getting an answer sooner than later. I can post particulars (IIS/NT/PHP versions, etc. tomorrow if needed). I know PHP is at least 4.x...

Is there any way to get IIS to execute .php files if they are added via an SSI include statement? Our setup is not doing this.

Here's the quick history. I took over a large intranet running on Netscape Enterprise on NT. No perl, no PHP, nothing but some kludgy javascript. I spent a lot of time at it but finally got PHP running under this system. Not wanting to rename and relink every page to .php extensions, I had (what I thought at the time) a brilliant idea. Using SSI, I could include PHP files even if the html file containing the SSI include was an .htm. I gave the includes .php extensions and IT WORKED! Oh joy! Rapture!

A month later, I find that IT hates NS Enterprise (says it crashes too often) and is switching over to IIS. It's my responsiblity to get PHP running, which I do (just yesterday). I see that php(info) works, but all my SSI-included .php's do not!

Is there any way to get this working? Is there something I missed? Is there any other alternative I can try that would allow me the .php's to run inside .htm's (and I don't think the IT staff would allow IIS to parse every file for php)?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

How about configure the server so it parses .html as a PHP file
network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

Post by network23 »

IT staff is worried about the performance hit if IIS has to parse every .htm file.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I don't think it would affect the performance that much.
network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

Post by network23 »

Here are the specs I promised... see if these might affect your opinion on a performance hit if IIS parses all .htm's

PHP 4.2.1
Server API: ISAPI
NT 4
IIS/4.0

Anything else I should list that might sway opinions on affecting performance?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

IIS is capable of SSI but by default it is enabled for .shtml and .shtm only.
If you add .htm it should work, too ;)
network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

Post by network23 »

IIS is capable of SSI but by default it is enabled for .shtml and .shtm only.
If you add .htm it should work, too
SSI's are running (we've already done your tip), but unlike under Netscape's server, .php's aren't processed in IIS's SSI's, the raw php code is just sent out to the rendered page, viewable in the source. Netscape would process all included php's before rendering the page, allowing for nested php's inside SSI includes.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

even when using <!--#exec cgi="path/to/php.exe file.php"--> ?
network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

Post by network23 »

I've never used exec before. I'll give it a try but first two questions...

Under NT, would the "path/to/php.exe" be the drive path (ie, starting with the drive letter)?

Following that path, is it possible/necessary to put the path/to/file.php or does the .php file need to go in a directory that's automatically searched by php for php files?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

network23
Forum Newbie
Posts: 6
Joined: Wed Sep 04, 2002 11:35 pm
Location: Illinois, USA

Post by network23 »

volka,

exec worked! Thanks for the suggestion!

I just replaced the "include virtual=" part with "exec cgi=" to the path of the php file and it ran as intended.
Post Reply