0

i am trying to create a nanoserver-iis-php8 docker image. when copying the instructions in php site to a docker file like this line RUN powershell -command c:\windows\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='c:\php\php-cgi.exe'] i get this error message when building the image:

ERROR ( message:Malformed collection indexer; format is [@position,name='value',name2='value2',...]. The @position specifier is optional, and be '@start', '@end', or '@N' where N is a numeric index into the collection. )

how do i fix this?

user605505
  • 59
  • 1
  • 3
  • 18
  • What is the basic image you used? – Lex Li Jul 02 '23 at 00:02
  • nanoserver/iis i tried to edit the config file (applicationhost.config) myself but i get a service unavailable error when trying to run the image as web server – user605505 Jul 02 '23 at 14:24
  • This command line looks ok, but there may be something we didn't notice somewhere, you can try to copy the command below and try again to see if it is the same problem. `C:\>%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='c:\{php_folder}\php-cgi.exe']` – samwu Jul 03 '23 at 07:12
  • tried it but still getting a non zero code when building .. maybe a different approach will be better, like updating the config files directly, instead of via cli? – user605505 Jul 05 '23 at 10:38

1 Answers1

0

You can also try using the C# code:

using (ServerManager serverManager = new ServerManager())
  {
     Configuration config = serverManager.GetApplicationHostConfiguration();

     ConfigurationSection fastCgiSection = config.GetSection("system.webServer/fastCgi");
     ConfigurationElementCollection fastCgiCollection = fastCgiSection.GetCollection();
     ConfigurationElement applicationElement = fastCgiCollection.CreateElement("application");
     applicationElement["fullPath"] = @"C:\PHP\php-cgi.exe";
     serverManager.CommitChanges();
  }
samwu
  • 3,857
  • 3
  • 11
  • 25