[ms4w-users] fcgid connexion problem

Alexandre Dubé adube at mapgears.com
Wed Jul 9 16:06:53 EDT 2008


Today's Topics:

   1. fastCgiServer with ms4w (Alexandre Dub?)
   2. Re: fastCgiServer with ms4w (Jeff McKenna)


----------------------------------------------------------------------

Message: 1
Date: Tue, 08 Jul 2008 16:32:44 -0400
From: Alexandre Dub? <adube at mapgears.com>
Subject: [ms4w-users] fastCgiServer with ms4w
To: ms4w mailing list <ms4w-users at lists.maptools.org>
Message-ID: <4873CEEC.90203 at mapgears.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi everyone,

  I'm trying to setup a fastCGIServer with ms4w and I can't figure out 
how to make it work.

  Here's what I actually did :

  - I first copied mod_fcgi.so to my apache/modules folder
  - Then, installed Visual C++ 2008 Redistributable Package
  - Then added to my httpd.conf the following lines :
      At line 117 : LoadModule fcgid_module modules/mod_fcgid.so
          (if I change the filename it generates an error, so I assume 
the module is loaded correctly)
      At line 420 : AddHandler fastcgi-script fcgi
      At line 138 : FastCgiConfig -minProcesses 2
          ( this line is to test if the module works correctly )

  - When I try to restart apache, I get the following error :

Syntax error on line 138 of C:/ms4w/Apache/conf/httpd.conf:
Invalid command 'FastCgiConfig', perhaps misspelled or defined by a 
module not i
ncluded in the server configuration

  I don't understand why it can't understand the 'FastCgiConfig' 
command, the module is supposed to be loaded...  Is there a way to know 
if the fastCgi is correctly loaded ?  Or does anybody know what's wrong 
with my configs ?  Something missing perhaps...

-- Alexandre Dubé Mapgears www.mapgears.com 
------------------------------ Message: 2 Date: Wed, 9 Jul 2008 01:08:39 
-0400 From: Jeff McKenna <jmckenna at gatewaygeomatics.com> Subject: Re: 
[ms4w-users] fastCgiServer with ms4w To: ms4w mailing list 
<ms4w-users at lists.maptools.org> Message-ID: 
<EB079AAD-57C2-4B9F-9EED-379691EDC43A at gatewaygeomatics.com> 
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes 
On 8-Jul-08, at 4:32 PM, Alexandre Dubé wrote:

> > Hi everyone,
> >
> > I'm trying to setup a fastCGIServer with ms4w and I can't figure out  
> > how to make it work.
> >
> > Here's what I actually did :
> >
> > - I first copied mod_fcgi.so to my apache/modules folder
> > - Then, installed Visual C++ 2008 Redistributable Package
> > - Then added to my httpd.conf the following lines :
> >     At line 117 : LoadModule fcgid_module modules/mod_fcgid.so
> >         (if I change the filename it generates an error, so I assume  
> > the module is loaded correctly)
> >     At line 420 : AddHandler fastcgi-script fcgi
> >     At line 138 : FastCgiConfig -minProcesses 2
> >         ( this line is to test if the module works correctly )
> >
> > - When I try to restart apache, I get the following error :
> >
> > Syntax error on line 138 of C:/ms4w/Apache/conf/httpd.conf:
> > Invalid command 'FastCgiConfig', perhaps misspelled or defined by a  
> > module not i
> > ncluded in the server configuration
> >
> > I don't understand why it can't understand the 'FastCgiConfig'  
> > command, the module is supposed to be loaded...  Is there a way to  
> > know if the fastCgi is correctly loaded ?  Or does anybody know  
> > what's wrong with my configs ?  Something missing perhaps...
> >
> > -- 
> > Alexandre Dubé
> > Mapgears
> > www.mapgears.com
> >
>   

Alexandre,

I found the existing MS4W bug with some notes on this module (http://bugzilla.maptools.org/show_bug.cgi?id=1631 
).  I have added your initial comments.  If you can add any further  
findings of yours to that bug that would be great.  To answer your  
questions I made some notes as I worked through it all, which I have  
added to that bug and included below:

FastCGI Config notes
====================

1) to see a list of loaded Apache modules:

    - cd to /Apache/bin
    - execute:
   			httpd -t -D DUMP_MODULES
   			
      With a fresh (no changes out of the box) MS4W you will see:

      Loaded Modules:
  		core_module (static)
  		win32_module (static)
  		mpm_winnt_module (static)
  		http_module (static)
     	...
  		setenvif_module (shared)
	 Syntax OK
	
2) Edit Apache/conf/httpd.conf and add the following:

   - line#117     LoadModule fcgid_module modules/mod_fcgid.so
   - line#420     AddHandler fastcgi-script fcgi

    Without installing the Visual C 2008 runtimes, if I try viewing  
the modules again I get the following error:

   	httpd: Syntax error on line 118 of C:/ms4w/Apache/conf/httpd.conf:  
Cannot load
   	C:/ms4w/Apache/modules/mod_fcgid.so into server: This application  
has failed to
   	start because the application configuration is incorrect.  
Reinstalling the
   	application may fix this problem.
   	
3) after installing Visual C 2008 runtimes (www.microsoft.com/downloads/details.aspx?FamilyID=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en) 
  try to view the modules again and look for the fcgid module at the  
end:

      Loaded Modules:
  		core_module (static)
  		win32_module (static)
  		mpm_winnt_module (static)
  		http_module (static)
     	...
  		setenvif_module (shared)
  		fcgid_module (shared)
	 Syntax OK

4) If I place the "FastCgiConfig -minProcesses 2" command on line#145  
(after the 2 existing </IfModule> tags), and try listing the modules  
again I get the error:

	Syntax error on line 145 of C:/ms4w/Apache/conf/httpd.conf:
	Invalid command 'FastCgiConfig', perhaps misspelled or defined by a  
module not
	included in the server configuration
	
Solution:

FastCgiConfig is actually a directive for the "mod_fastcgi" module  
(from fastcgi.com).  In our case however, we are using "mod_fcgid",  
and it has its own directives, which are all documented on http://fastcgi.coremail.cn/doc.htm

Therefore, around line#145 (after the existing </IfModule> tags), we  
could have:

	<IfModule fcgid_module>
   		DefaultMinClassProcessCount 3
	</IfModule>
	
Give those directives a try!

Notes:
******

- the above testing was all done through commandline, which means that  
PATHs are often set nicely.  More testing must occur with mod_fcgid  
through the browser to make sure that appropriate environment  
variables are being set (these are documented on  http://fastcgi.coremail.cn/doc.htm)
- the above settings in httpd.conf will be added to the ms4w 2.2.8  
release (shortly!)


---
Jeff McKenna
FOSS4G Consulting and Training Services
http://www.gatewaygeomatics.com/


----------------------------------------------------------------------------------

Hi Jeff,

  Thank you very much for the quick answer.

  I have an other problem, unfortunately.  Here's the config I'm using :

LoadModule fcgid_module modules/mod_fcgid.so

<Directory "/ms4w/Apache/cgi-bin">
    SetHandler fcgid-script
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>

<IfModule fcgid_module>
    IPCCommTimeout 60
    IdleTimeout 60
    DefaultMinClassProcessCount 2
    DefaultMaxClassProcessCount 20
</IfModule>

And I added this line below my only layer in my mapfile :

PROCESSING "CLOSE_CONNECTION=DEFER"


When I try to load a map, I get the following error in my mapserver.log (I changed the name of the user, dbname, password and layer for '....' in this example) :

[Wed Jul 09 15:26:41 2008].375000 CGI Request 1 on process 6508
[Wed Jul 09 15:26:41 2008].437000 FAILURE!!![Wed Jul 09 15:26:41 2008].437000 msPOSTGISLayerOpen(): Query error. couldnt make connection to DB with connect string 'user=.... password=.... dbname=.... host=127.0.0.1 port=5432'.

Error reported was 'could not create socket: The requested service provider could not be loaded or initialized.
 (0x0000277A/10106)
'.


This error occured when trying to make a connection to the specified postgresql server.  

Most commonly this is caused by 
(1) incorrect connection string 
(2) you didnt specify a 'user=...' in your connection string 
(3) the postmaster (postgresql server) isnt running 
(4) you are not allowing TCP/IP connection to the postmaster 
(5) your postmaster is not running on the correct port - if its not on 5432 you must specify a 'port=...' 
 (6) the security on your system does not allow the webserver (usually user 'nobody') to make socket connections to the postmaster 
(7) you forgot to specify a 'host=...' if the postmaster is on a different machine
(8) you made a typo 
  
[Wed Jul 09 15:26:41 2008].437000 msDrawMap(): Image handling error. Failed to draw layer named '....'.


Is it possible that I can't connect to my postgres database using fcgid ?  I tried to change the host to 'localhost' in the mapfile and I get the same kind of error.  I checked in the Windows task manager to see if mapserv.exe was using the same username (SYSTEM) and it did...

I'm a little confused, again.  Can you help me out ?



More information about the ms4w-users mailing list