views:

787

answers:

2

Hi all,

My goal is to add php Extension to IIS6 and IIS 7 via Code in C# using WMi (System.Management). I cant use DirectoryEntry.

I am stuck with adding a new ScriptMap Object to IIS 6/IIS7.

I have read some posts at here and there and heard that adding new WMi object from Scratch is difficult.

I want to enable IIS 6/IIS7 to handle php as well as aspx files and be able to process them. I have extracted php zip archive to a directory on my system (not installed it). The propblem is i am able to modify existing ScriptMap objects but i dont get to understand the add a new ScriptMap Objects.

Also i am not sure whether adding the a new extensiuon handler to ScriptMap will solve the problem or not.

Please guide.

Thanks

A: 

Try the PHP installer, it has an option for IIS.. why reinvent the wheel?

PHP.net installation

Talvi Watia
Actually, i am re-inventing the wheel. I know that the installer does so automatically,I also know that we can manually do so via IIS Manager.I am interested in doing it programmatically.
Steve Johnson
@talvi - not helpful, if you're building provisioning systems you need to be able to add and remove scriptmaps/handlermappings programmatically.
Kev
A: 

@Kev. Yes. Got it. Problem solved through Thanks Kev . :-)

The solution was

  1. to add "*.php" extension in "Extensions" Property of ScriptMap Array and "ScriptProcessor" Property to be set to the path of the "php5isapi.dll".

  2. The second thing was to add the "Default.php" (or any other suitable default php document) to zeroth index of "DefaultDoc" Array among others like "Default.aspx, Default.htm, Default.html, Default.asp" etc.

  3. The third thing was to enable/Allow the PHP ISAPI Extension. IIsWebService.EnableExtension did the trick.

Thanks again kev for providing me the starting point.

Steve Johnson
@Steve - woo...not sure where I helped there :). Just a note though, you should be using the FastCGI bits for IIS6/7 these days when running PHP. http://www.iis.net/expand/FastCGI
Kev