0

I have a shortcut:

c:/path/to/app1/current_php-cgi.exe.lnk

I am trying to do this:

FcgidWrapper "c:/path/to/app1/current_php-cgi.exe.lnk" .php

And Apache has no issue with the syntax but after reboot, any requests for a PHP file result in this error:

[Mon Jun 12 12:57:50.962946 2023] [fcgid:error] [pid 25564:tid 680]
(OS 193)%1 is not a valid Win32 application.:
mod_fcgid: can't run c:/path/to/app1/current_php-cgi.exe.lnk

^ separated to multi-line for easier reading

Is my desire simply unsupported?


If you want to know why, it's because I wish to have absolutely minimal downtime/reconfiguration when a PHP upgrade needs to happen. I want "app1" to have it's own PHP install and let app1 happily live even if "app2" might be ready for a PHP upgrade or maybe "app3" requires an older version of PHP.

MonkeyZeus
  • 260
  • 1
  • 12

2 Answers2

2

a link is not an executable that can be run as is, so that's not surprising. The error message is on point:

is not a valid Win32 application.

Hence

Is my desire simply unsupported?

Yes, but it's also that it doesn't make any sense. Instead of specifying a link there, just specify the path to the actual executable. That's why that path is configurable.

I want "app1" to have it's own PHP install and let app1 happily live even if "app2" might be ready for a PHP upgrade or maybe "app3" requires an older version of PHP.

You can have different FCGI wrappers for different locations. That's way more sensible than trying to bend some link.

Marcus Müller
  • 500
  • 4
  • 13
  • So would this be a limitation of `mod_fcgid` not resolving `lnk` files? I'm able to successfully use `lnk`s in `bat` files and it has no problem with them. – MonkeyZeus Jun 13 '23 at 14:30
  • no, that's not a restriction of mod_fcgid. You're simply attributing properties to .lnk files that they don't have. In a batch file, the command interpreter reads the link file and just executes the code. That happens only there and when you double-click in windows explorer. A lnk file on windows is *not* in a way equivalent to the executable it links to. – Marcus Müller Jun 13 '23 at 14:32
  • I figured it out finally, see my answer below =) – MonkeyZeus Jun 23 '23 at 19:15
0

I've found that the most cross-compatible way to achieve my goal is to use a symlink to PHP's parent folder:

cd C:\path\to\app1\php
mklink /d current_php_dir C:\path\to\app1\php\8.2.1_x64

and then use this in the Apache config:

FcgidWrapper "c:/path/to/app1/php/current_php_dir/php-cgi.exe" .php

This now allows for the Apache app1 vhost, scheduled app1 tasks, and shell executions made by app1 to seamlessly point to the same PHP version at all times.

MonkeyZeus
  • 260
  • 1
  • 12