Keep Server Online
  
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
  
or
  
 
  
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
  
Thank You! Steffen
  
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |    |   
 | 
     Topic: cgi access with PHP 8.4.5 | 
 |   
| Author | 
  | 
 
s.pellegrino
 
 
  Joined: 09 Sep 2020 Posts: 4 Location: Marseille
  | 
 Posted: Tue 01 Apr '25 13:33    Post subject: cgi access with PHP 8.4.5 | 
     | 
 
  | 
 
Hi everybody,
 
 
With windows 11, PHP 8.4.5, Apache latest, I do a "classic" cgi vhost.
 
 
 	  | Code: | 	 		  Listen 8181
 
<VirtualHost *:8181>
 
   ServerName   www.ok.com                <- mapped on 127.0.0.1
 
   DocumentRoot "F:/Sites/www.ok.com"
 
   
 
   <Directory "F:/Sites/www.ok.com">
 
       Options Indexes ExecCGI
 
      AllowOverride All
 
        Require all granted
 
    </Directory>
 
 
    DirectoryIndex index.php index.html
 
 
    ScriptAlias /cgi-bin/ "F:/Sites/www.ok.com/"
 
   
 
   AddType    application/x-httpd-php .php
 
   
 
   AddHandler application/x-httpd-php .php
 
   Action application/x-httpd-php "E:/php-8.4.5-nts-Win32-vs17-x64/php-cgi.exe"
 
   
 
   ErrorLog  logs/www_ok_com_error.log
 
   CustomLog logs/www_ok_com_access.log combined
 
   LogLevel warn
 
</VirtualHost>
 
 | 	  
 
 
 
But on:
 
[url]curl http://www.ok.com/cgi-bin/test.php[/url]
 
 
 
I get :
 
 	  | Code: | 	 		  HTTP/1.1 400 Bad Request
 
Date: Tue, 01 Apr 2025 11:32:54 GMT
 
Server: Apache/2.4.63 (Win64)
 
Connection: close
 
Content-Type: text/html; charset=iso-8859-1 | 	  
 
 
  
 
What am I doing wrong ?
 
 
Thanls | 
 
  | 
 
| Back to top | 
 | 
 
tdonovan Moderator
 
  Joined: 17 Dec 2005 Posts: 616 Location: Milford, MA, USA
  | 
 Posted: Wed 02 Apr '25 2:57    Post subject: Action directive takes a URI | 
     | 
 
  | 
 
The second argument to the Action directive is a URL-path, not a filename.
 
 
You could copy php-cgi.exe   to F:/Sites/www.ok.com/, since you already have a ScripAlias for it and permissions set by a Require directive; then change your Action directive to:  	  | Code: | 	 		  | Action application/x-httpd-php /cgi-bin/php-cgi.exe | 	  
 
It might be better to create a new ScripAlias to E:/php-8.4.5-nts-Win32-vs17-x64/php-cgi.exe, set its permission with Require (inside a Location directive), and use this for the second argument.   For example, if you call the new ScripAlias "/PHP-CGI" you could use this: 	  | Code: | 	 		  ScriptAlias /PHP-CGI "E:/php-8.4.5-nts-Win32-vs17-x64/php-cgi.exe"
 
<Location /PHP-CGI>
 
   Require all granted 
 
</Location>
 
AddHandler application/x-httpd-php .php
 
Action application/x-httpd-php /PHP-CGI
 
 | 	 
  | 
 
  | 
 
| Back to top | 
 | 
 
s.pellegrino
 
 
  Joined: 09 Sep 2020 Posts: 4 Location: Marseille
  | 
 Posted: Wed 02 Apr '25 9:24    Post subject: cgi access with PHP 8.4.5 | 
     | 
 
  | 
 
Yes, that's pretty smart...
 
Thanks for your help ! | 
 
  | 
 
| Back to top | 
 | 
 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Wed 02 Apr '25 15:24    Post subject:  | 
     | 
 
  | 
 
| Why cgi? It is pretty slow. You could use FastCGI. | 
 
  | 
 
| Back to top | 
 | 
 
s.pellegrino
 
 
  Joined: 09 Sep 2020 Posts: 4 Location: Marseille
  | 
 Posted: Thu 03 Apr '25 10:49    Post subject:  | 
     | 
 
  | 
 
 	  | James Blond wrote: | 	 		  | Why cgi? It is pretty slow. You could use FastCGI. | 	  
 
 
Yes, you're right, but the client wants only that !   | 
 
  | 
 
| Back to top | 
 | 
 
 
 
 
 | 
 
 
 |  
 
 |  
  |   
 |