Lazarus

Programming => Networking and Web Programming => Topic started by: bobo on May 31, 2011, 07:45:40 pm

Title: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: bobo on May 31, 2011, 07:45:40 pm
I've created this readme in the past few days as I was running some tests, hope it will help people set up and use FCGI with Lazarus/FPC, or at least help to understand it better :)
Note, you will need the latest SVN version of /packages/fcl-web/ of FPC for everything to work as explained here (version 2.5.1 or later).
There are also example programs under /packages/fcl-web/examples/  . Many of them has all three of CGI/FCGI/Apache module versions.

===============================================================================
FCGI-README.txt
Last modified: Attila Borka 05/31/2011
-------------------------------------------------------------------------------
This readme will try to explain and help developers how to be able to
use the FastCGI protocol in Lazarus (package fpweb/lazweb) and FPC
(/packages/fcl-web) applications with the Apache web server.

There are two FCGI implementations we are able to use at the moment (FPC
rev17597 /2.5.1/) with FPC/Lazarus:

1. mod_fcgid maintained by Apache (ASF) http://httpd.apache.org/mod_fcgid/
Easy to set up and use, Apache develops and maintains it. Just needs a
download/install and it is ready to go, even on Linux.
There are a lot of options and fine tuning that can be used, please refer to
their documentation at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html .

2. mod_fastcgi from http://www.fastcgi.com/ the original FCGI "inventors"
The latest downloads are available from http://www.fastcgi.com/dist/ . Do not
be alarmed if the latest one is years old. FCGI is a very stable protocol
since many years (started in 1996).
On Linux, you will need to compile the mod_fastcgi module from the source
codes, as binaries are only available for Windows as a DLL.
Note, that mod_fastcgi supports the use of External FCGI Servers, which makes
it possible to run the FCGI application from within Lazarus for example, and
be able to debug it with the GUI on the fly while it is generating the
response pages. This can be a good choice for a development environment.
The documentation is at http://www.fastcgi.com/drupal/node/6 .


There are benefits to use both, everyone needs to decide which one fits their
needs the best for a development environment or a live web server after some
research on these modules.

Do not forget, that unless you use the External FCGI Server way, you need to
restart your web server every time you recompile your FCGI program.
In case you use the External FCGI Server, you need to restart the application
itself after every recompile for the changes to take effect in the web server
responses. The Apache server does not need to be restarted every time in this
latter case.

===============================================================================
1. mod_fcgid from Apache
1.1 on Windows
1.2 on Linux
2. mod_fastcgi from fastcgi.com
2.1 on Windows
2.1 on Linux
===============================================================================

1. mod_fcgid from Apache:
=========================

1.1 mod_fcgid from Apache on Windows:
-------------------------------------
Setup Steps:
1.1.1 Download from http://httpd.apache.org/download.cgi#mod_fcgid the latest
Windows zip file and unpack as it instructs you to, over the installed Apache
directory. This puts the mod_fcgid.* files under the current /modules
directory of Apache.

1.1.2 Now, mod_fcgid is ready to be used as soon as we load it with Apache.

1.1.3 If you have not done so yet, compile your FCGI application.

1.1.4 Then, edit the Apache /conf/httpd.conf file and add to the end:
############
LoadModule fcgid_module "modules/mod_fcgid.so"
<IfModule mod_fcgid.c>
  <Directory "<Path_To_Your_FCGI_application>">
    SetHandler fcgid-script
#    Options +ExecCGI  <- not needed if ScriptAlias is used below
    Order allow,deny
    Allow from all
  </Directory>
#optionally, to shorten the URL and to not display the executable file name
#(if ScriptAlias is used, no +ExecCGI is needed above)
  ScriptAlias /myfcgid "<Path_To_Your_FCGI_application>/<Your_FCGI_application>"
</IfModule>
############
Example:
LoadModule fcgid_module "modules/mod_fcgid.so"
<IfModule mod_fcgid.c>
  <Directory "C:/My Programs/LazarusFCGITest">
    SetHandler fcgid-script
    Order allow,deny
    Allow from all
  </Directory>
  ScriptAlias /myfcgid "C:/My Programs/LazarusFCGITest/helloworld.exe"
</IfModule>

Note, there are many ways to configure the FCGI applications, this is just but
one example. You can check the Apache and mod_fcgid documentation for
alternatives.

1.1.5 Start/Restart your Apache server so it will load your FCGI application.
If everything went according to plan, your FCGI application should be listed
in the Windows task manager as running.

1.1.6 Open your web browser and try to call your new FCGI application.
Example:
http://127.0.0.1:8080/myfcgid/func1call
or
http://127.0.0.1/myfcgid/func1call
depending on your Apache installation and configuration. "myfcgid" is the
ScriptAlias name specified for the FCGI application, func1call is the action
name we want to call within our default web module. If you have multiple web
modules, you can enter the desired web module name before the action name, for
example:
http://127.0.0.1:8080/myfcgid/webmodule1/func1call
or
http://127.0.0.1/myfcgid/webmodule1/func1call

If there is any problem, you can try and check the Apache error.log for clues.


1.2 mod_fcgid from Apache on Linux:
-----------------------------------
Setup Steps:
1.2.1 Install the mod_fcgi module for Apache with your distro's package
manager.
Example on Ubuntu:
sudo apt-get install libapache2-mod-fcgid

This downloads, installs and configures mod_fcgid without the need to do
anything else.

1.2.2 Now, mod_fcgid is ready to be used as soon as we load it with Apache.
mod_fcgid.so should be sitting in the /usr/lib/apache2/modules/ directory (on
Ubuntu)

1.2.3 If you have not done so yet, compile your FCGI application.

1.2.4 Edit the Apache configuration file (/etc/apache2/apache2.conf on Ubuntu)
and add to the end:
############
LoadModule fcgid_module "<Path_To_Mod>/mod_fcgid.so"
<IfModule mod_fcgid.c>
  <Directory "<Path_To_Your_FCGI_application>">
    SetHandler fcgid-script
#    Options +ExecCGI  <- not needed if ScriptAlias is used below
    Order allow,deny
    Allow from all
  </Directory>
#optionally, to shorten the URL and to not display the executable file name
#(if ScriptAlias is used, no +ExecCGI is needed above)
  ScriptAlias /myfcgid "<Path_To_Your_FCGI_application>/<Your_FCGI_application>"
</IfModule>
############
Example:
LoadModule fcgid_module "/usr/lib/apache2/modules/mod_fcgid.so"
<IfModule mod_fcgid.c>
  <Directory "/home/johndoe/LazarusFCGITest">
    SetHandler fcgid-script
    Order allow,deny
    Allow from all
  </Directory>
  ScriptAlias /myfcgid "/home/johndoe/LazarusFCGITest/helloworld"
</IfModule>

(the project was compiled into directory /home/johndoe/LazarusFCGITest/ , and
the FCGI application is called helloworld with no file extension)

Note, there are many ways to configure the FCGI applications, this is just but
one example. You can check the Apache and mod_fcgid documentation for
alternatives.

1.2.5 Start/Restart your Apache server so it will load your FCGI application.
If everything went according to plan, and you do a "sudo netstat -l"
(on Ubuntu) from a terminal window, there should be a new line in the result
list looking something like this:
... LISTENING   XXXX   /var/lib/apache2/fcgid/sock/...
indicating, that the Apache mod_fcgid module has loaded your FCGI application.

1.2.6 Open your web browser and try to call your new FCGI application.
Example:
http://127.0.0.1/myfcgid/func1call

"myfcgid" is the ScriptAlias name specified for the FCGI application, and
func1call is the action name we want to call within our default web module.
If you have multiple web modules, you can enter the desired web module name
before the action name, for example:
http://127.0.0.1/myfcgid/webmodule1/func1call .

If there is any problem, you can try and check the Apache error.log for clues.


2. mod_fastcgi from fastcgi.com:
================================
Unlike the Apache developed mod_fcgid, mod_fastcgi has two main operating
modes for FCGI applications. One is very similar to mod_fcgid (where Apache
itself loads the FCGI application at startup), and one called External FCGI
Server mode. With this latter, Apache will not load the FCGI application at
startup, but it has to be running on its own when a web request arrives
(either as a system service/daemon, or a simple running application) and
listening. This makes it possible to run the FCGI application from within a
debugger interactively, to see/track the request handling like any normal GUI
application debugging.

2.1 mod_fastcgi from fastcgi.com on Windows:
--------------------------------------------
Setup Steps:
2.1.1 Download the latest SNAP or stable DLL from http://www.fastcgi.com/dist/
and put it into the Apache /modules/ directory.

2.1.2 If you have not done so yet, compile your FCGI application.
In case you want to set up an External FCGI Server, then you must specify a
port number in your main project file (.lpr) before the Application.Run
instruction (this is the only change needed).
Example:
<...snip...>
  Application.Initialize;
  Application.Port:=9999;//Port the FCGI application is listening on
  Application.Run;
<...snip...>

2.1.3 Edit the Apache /conf/httpd.conf file and add to the end:

 2.1.3.a External FCGI Server
############
LoadModule fastcgi_module "modules/<mod_fastcgi_DLL_name>"
<IfModule mod_fastcgi.c>
  <Directory "<Path_To_Your_FCGI_application>">
#    Options +ExecCGI  <- not needed if ScriptAlias is used below
    Order allow,deny
    Allow from all
  </Directory>
#External FCGI app, has to be started and running when a request comes in
  FastCgiExternalServer "<Path_To_Your_FCGI_application>/<Your_FCGI_application>" -host 127.0.0.1:<Port> -idle-timeout 30 -flush
#optionally, to shorten the URL and to not display the executable file name (if used, no +ExecCGI is needed above):
  ScriptAlias /myfcgi "<Path_To_Your_FCGI_application>/<Your_FCGI_application>"
</IfModule>
############
Example:
LoadModule fastcgi_module "modules/mod_fastcgi-2.4.6-AP22.dll"
<IfModule mod_fastcgi.c>
  <Directory "C:/My Programs/LazarusFCGITest">
    Order allow,deny
    Allow from all
  </Directory>
  FastCgiExternalServer "C:/My Programs/LazarusFCGITest/helloworld.exe" -host 127.0.0.1:9999 -idle-timeout 30 -flush
  ScriptAlias /myfcgi "C:/My Programs/LazarusFCGITest/helloworld.exe"
</IfModule>

 2.1.3.b Regular FCGI Server
Replace the FastCgiExternalServer line above with
  FastCgiServer "<Path_To_Your_FCGI_application>/<Your_FCGI_application>" -idle-timeout 30

Example:
LoadModule fastcgi_module "modules/mod_fastcgi-2.4.6-AP22.dll"
<IfModule mod_fastcgi.c>
  <Directory "C:/My Programs/LazarusFCGITest">
    Order allow,deny
    Allow from all
  </Directory>
  FastCgiServer "C:/My Programs/LazarusFCGITest/helloworld.exe" -idle-timeout 30
  ScriptAlias /myfcgi "C:/My Programs/LazarusFCGITest/helloworld.exe"
</IfModule>

2.1.4 Start/Restart your Apache server.
If you will use the FastCgiExternalServer, then start your application
manually, so it can start accepting incoming requests from the web server.
If you use the FastCgiServer, then your FCGI application should be launched
by the Apache server when it starts and should be listed in the Windows task
manager as running.

2.1.5 Open your web browser and try to call your new FCGI application.
Example:
http://127.0.0.1:8080/myfcgi/func1call
or
http://127.0.0.1/myfcgi/func1call
depending on your Apache installation and configuration.

"myfcgi" is the ScriptAlias name specified for the FCGI application, and
func1call is the action name we want to call within our default web module.
If you have multiple web modules, you can enter the desired web module name
before the action name, for example:
http://127.0.0.1:8080/myfcgi/webmodule1/func1call
or
http://127.0.0.1/myfcgi/webmodule1/func1call

If there is any problem, you can try and check the Apache error.log for clues.


2.2 mod_fastcgi from fastcgi.com on Linux:
------------------------------------------
Setup Steps:
2.2.1 There are no binaries offered for download for Linux, so we need to get
the mod_fastcgi source codes from http://www.fastcgi.com/dist/ and compile it.

 2.2.1.1. If the Apache development package headers are not installed, then
we need to get them first:
(on Ubuntu)
>sudo apt-get install apache2-dev

 2.2.1.2. Get the fastcgi module sources (get the latest SNAP or highest
version stable release from http://www.fastcgi.com/dist/ )

>cd /home/johndoe
>wget http://www.fastcgi.com/dist/mod_fastcgi-xxxxxxxxxxx.tar.gz

Example: wget http://www.fastcgi.com/dist/mod_fastcgi-SNAP-0910052141.tar.gz

 2.2.1.3. Unpack the source code files.
>tar -xzf mod_fastcgi-*.tar.gz

 2.2.1.4. Configure the makefile (we use Apache 2.2, so need the Makefile.AP2).
>cd mod_fastcgi-*
>cp Makefile.AP2 Makefile

 2.2.1.5. Edit the copied Makefile and set top_dir to the proper apache source
directory created by the Apache development package install. For example, on
Ubuntu it is /usr/share/apache2 (containing the .mk file).

 2.2.1.6. Compile and install (on Ubuntu)
>make
>sudo make install

2.2.2. Now, we should have a mod_fastcgi.so in /usr/lib/apache2/modules (on
Ubuntu)

2.2.3. If you have not done so yet, compile your FCGI application.
In case you want to set up an External FCGI Server, then you must specify a
port number in your main project file (.lpr) before the Application.Run
instruction (this is the only change needed).
Example:
<...snip...>
  Application.Initialize;
  Application.Port:=1234;//Port the FCGI application is listening on
  Application.Run;
<...snip...>

2.2.4 Edit the Apache configuration file (/etc/apache2/apache2.conf on Ubuntu)
and add to the end:
 2.2.4.a External FCGI Server
############
LoadModule fastcgi_module "<Path_To_Mod>/mod_fastcgi.so"
<IfModule mod_fastcgi.c>
  <Directory "<Path_To_Your_FCGI_application>">
#    Options +ExecCGI  <- not needed if ScriptAlias is used below
    Order allow,deny
    Allow from all
  </Directory>
#External FCGI app, has to be manually started and running when a request comes in
  FastCgiExternalServer "<Path_To_Your_FCGI_application>/<Your_FCGI_application>" -host 127.0.0.1:<Port> -idle-timeout 30 -flush
#optionally, to shorten the URL and to not display the executable file name (if used, no +ExecCGI is needed above):
  ScriptAlias /myfcgi "<Path_To_Your_FCGI_application>/<Your_FCGI_application>"
</IfModule>
############
Example:
LoadModule fastcgi_module "/usr/lib/apache2/modules/mod_fastcgi.so"
<IfModule mod_fastcgi.c>
  <Directory "/home/johndoe/LazarusFCGITest">
    Order allow,deny
    Allow from all
  </Directory>
  FastCgiExternalServer "/home/johndoe/LazarusFCGITest/helloworld" -host 127.0.0.1:1234 -idle-timeout 30 -flush
  ScriptAlias /myfcgi "/home/johndoe/LazarusFCGITest/helloworld"
</IfModule>

 2.2.4.b Regular FCGI Server
Replace the FastCgiExternalServer line above with
  FastCgiServer "<Path_To_Your_FCGI_application>/<Your_FCGI_application>" -idle-timeout 30

Example:
LoadModule fastcgi_module "/usr/lib/apache2/modules/mod_fastcgi.so"
<IfModule mod_fastcgi.c>
  <Directory "/home/johndoe/LazarusFCGITest">
    Order allow,deny
    Allow from all
  </Directory>
  FastCgiServer "/home/johndoe/LazarusFCGITest/helloworld" -idle-timeout 30
  ScriptAlias /myfcgi "/home/johndoe/LazarusFCGITest/helloworld"
</IfModule>

(the project is compiled into directory /home/johndoe/LazarusFCGITest/ , and
the FCGI application is called helloworld with no file extension)

Note, there are many ways to configure the FCGI applications, this is just but
one example. You can check the Apache and mod_fastcgi documentation for
alternatives. For example, some more information available at
http://www.fastcgi.com/docs/faq.html#typical_httpd.conf

2.2.5 Start/Restart your Apache server.
If FastCgiExternalServer is used, then start your application manually, so it
can start accepting incoming requests from the web server.
On the other hand, if FastCgiServer is used and everything went according to
plan, then the Apache error.log should contain a warning message about your
FCGI application, saying that it was started. Something like:
[warn] FastCGI: server "/home/johndoe/LazarusFCGITest/helloworld" started...

2.2.6 Open your web browser and try to call your new FCGI application.
Example:
http://127.0.0.1/myfcgi/func1call
"myfcgi" is the ScriptAlias name specified for the FCGI application, and
func1call is the action name we want to call within our default web module.
If you have multiple web modules, you can enter the desired web module name
before the action name, for example:
http://127.0.0.1/myfcgi/webmodule1/func1call

If there is any problem, you can try and check the Apache error.log for clues.

===============================================================================
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: nicke85 on June 20, 2011, 11:10:09 pm
Thank you for your time bobo..tutorial is very nice..do you plan to make pdf maybe!? 8-)
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: bobo on June 20, 2011, 11:19:40 pm
I did not plan to make it in other formats, anyone is free to do so.  This is now included in the latest FPC SVN under /packages/fcl-web/src/base/FCGI-README.txt

If something is not clear, please let me know so the file can be updated.

We have also moved (as well as updated/fixed for the latest fcl-web changes) the fpweb examples from Lazarus to FPC under /packages/fcl-web/examples/ because LCL is no longer required for fpweb applications.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: xenblaise on June 25, 2011, 05:09:36 am
hi
Just want to ask first before applying this on the near future,
Thus this make my web app rans faster?

thanks
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: bobo on June 25, 2011, 07:47:31 am
The short answer: Yes.

The long answer and the comparison between CGI and FCGI can be found here:
http://www.fastcgi.com/drupal/node/6?q=node/15

However, for simple, low traffic websites the difference might not be noticeable.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: jixian.yang on July 26, 2011, 05:11:39 pm
FastCGI can not be found in SVN18020 of Freepascal.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: Silvio Clécio on August 02, 2011, 01:30:24 am
The long thread about FCGI:

http://www.mail-archive.com/lazarus@lists.lazarus.freepascal.org/msg20061.html
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: kodok_buncit on August 12, 2011, 10:24:29 am
hi bobo and all..
is this fcgi app multhithread?
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: bobo on August 20, 2011, 07:49:00 pm
kodok_buncit:
The CGI modules are handling one request at a time - there is no need for multi-thread theoretically - because the web server starts up a new instance of the module for each request. If there are multiple simultaneous requests are arriving, then there will be multiple instances of the CGI application running at the same time.

For FCGI modules, since they are sitting in the memory, it would be possible to do multi-threading, but the standard is to have a queue for multiple request handling and the protocol has an identifier for every request so the server does not mixes up the responses from the same FCGI application instance.
A "pseudo" multi-threading is done kind of the same way as with CGI modules (where every request spawns a new copy of the CGI application) because the web server (Apache in these examples) can spawn multiple instances of the FCGI module to sit in the memory and to wait for incoming requests.
There are many many configuration settings for the web server on how to do the FCGI request/response handling, the best if you read up on them in the documentation.
For example, how many instances of the FCGI application to spawn, after how many requests to restart an FCGI instance, after how much idle time to restart an FCGI instance, etc. (these vary between the mod_fcgid and mod_fastcgi, each has their own settings)
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: kodok_buncit on August 20, 2011, 11:21:16 pm
thanks bobo, i'm curious about how implemented connection pooling(database) on fcgi environment and share object instance accross all client/request so the app can be more efficient.
I will read more about fastcgi
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: GiovanniF on February 27, 2012, 09:14:29 am
" using fpweb/fcl-web for Windows/Linux"

How can one "use fpweb/fcl-web" with LINUX?

Does ANYONE know a way to install the components ( fpweb ) under LINUX
since the package ( lpk ) file is missing?

Thanks for ANY helpö.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: Leledumbo on February 28, 2012, 04:35:19 am
Quote
How can one "use fpweb/fcl-web" with LINUX?

Does ANYONE know a way to install the components ( fpweb ) under LINUX
since the package ( lpk ) file is missing?

Thanks for ANY helpö.
Missing? What do you have under components/fpweb then?
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: GiovanniF on March 02, 2012, 12:47:47 pm
Well......

Read the message:  I am talking about LINUX version of fpweb.

IF you go to the components DIR and look inside the fpwep component DIR
you will see that the file weblaz.lpk is MISSING.

Have a nice day.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: BigChimp on March 02, 2012, 02:29:41 pm
On Debian x64 with FPC fixes_2.6, Lazarus trunk (today) I have:
Code: [Select]
ls -al /home/pascaldev/lazarus/components/fpweb/weblaz.lpk
-rw-r--r-- 1 pascaldev pascaldev 3867 Feb 18 15:16 /home/pascaldev/lazarus/components/fpweb/weblaz.lpk

It compiles as well...

Perhaps you have a faulty download/buggy snapshot/svn version?

Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: TheBlackSheep on March 29, 2012, 01:39:21 pm
Hi all
 
I struggled with this for a while but think I'm getting somewhere now;

Using the httpd-2.4.1-win32-ssl_0.9.8t.zip  & mod_fcgid-2.3.7-win32.zip from ApacheLounge - installed apache as a service and put the fcgid module in the modules folder in the apache folder structure.

Created a folder "C:\FastCGI" and set the following in the apache http.conf

Code: [Select]
<Directory "C:/FastCGI">
Options All
AllowOverride All
Require all granted
</Directory>

LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
  <Directory "C:/FastCGI">
   SetHandler fcgid-script
    Order allow,deny
    Allow from all
  </Directory>
  ScriptAlias /myfcgid "C:/FastCGI/helloworld.exe"
  ScriptAlias /fcgilist "C:/FastCGI/listrecords.exe"
</IfModule>

The bit I struggled with was that the demos have the listening "port" set to 2015 in the application source (the lpr file) - once you comment this out it seems to work fine with this setup - both applications are launched the first time they are called from the browser and remain in memory for each subsequent request.

Using the other fastcgi dll (i.e. not the apache fcgid module but the fastcgi module) with the dll renamed and the following configuration (the above fcgi version commented out)

LoadModule fastcgi_module modules/mod_fastcgi-2.4.6-AP22.so

I get an error trying to start apache;

"cannot load C:/Apache24/modules/mod_fastcgi-2.4.6-AP22.so into server: The specified procedure could not be found."

so this version might not work with Apache 2.4.1 - does anyone know of a verison that does or have I missed something?

I'm not really bothered about this latter module unless it's the only way to do realtime debugging so the question is using apache's own fcgid module (the first setup) is there an easy way to setup the configuration to do realtime debugging (i.e. set breakpoints etc)?

TheBlackSheep
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: bobo on November 22, 2012, 09:34:19 am
Quote
"so this version might not work with Apache 2.4.1 - does anyone know of a verison that does or have I missed something?"

mod_fastcgi does not seem to support Apache 2.4.X , the maintenance is totally stopped on the project it seems.
However, Apache 2.4.X has a new way to do the same functionality now, to do external FCGI server (FastCgiExternalServer) via the new mod_proxy_fcgi module.
I will update the top post once it is figured out how to make it work with fpc/lazarus , and the SVN is updated for fpc as needed to support it. Most probably this new way will be the preferred FCGI external server functionality instead of the old third party mod_fastcgi .

mod_fcgid still works as before, so we still have a perfectly working FCGI way with the latest Apache.
Both mod_fcgid and mod_proxy_fcgi are included in Apache from 2.3.X .

BTW, mod_fcgid is not for real time debugging (unless you are using log files) because in this case Apache loads the FCGI application at startup so there is no way to use a debugger like with the mod_fastcgi method (or with the new mod_proxy_fcgi module).
The  two latter you need to start the FCGI app yourself, hence you can use a debugger to execute them.
Compared to the debugging benefits of the two latter ones, mod_fcgid instead might be a good way for live web servers though, because Apache can start the FCGI app instances as needed, automatically.

Quote
"The bit I struggled with was that the demos have the listening "port" set to 2015 in the application source (the lpr file) - once you comment this out it seems to work fine with this setup - both applications are launched the first time they are called from the browser and remain in memory for each subsequent request."
The port is only used for the mod_fastcgi  FastCgiExternalServer mode (and the new Apache 2.3.X+ mod_proxy_fcgi module) . All other modes do not need that line because they are not using a port to listen on.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: GiovanniF on March 07, 2014, 02:26:54 pm
One simple question:

Using this method:

AResponse.Contents.LoadFromFile('aaa.html');

HOW do I incluse a image into my 'aaa.html' like

<img src="someimage.jpg"> ?

Thanks in advance.

Rgds

GiovanniF
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: RalphMuc on March 31, 2014, 07:35:34 pm
Hi there

thanks for the docu. Silvio's FastCGI Sample works fine.
Do you know how to pass environment Vars to fastcgi ?


Code: [Select]
procedure TMyAction.Get;
begin

 for I := 1 to ParamCount do
   WriteLn('Param ' + inttostr(I)  +  ': ' + ParamStr(I)); 

 WriteLn( 'myREMOTE_ADDR: ' + GetEnvironmentVariable('myREMOTE_ADDR') );
 WriteLn( 'BROOK_CLT_ENV_HTTP_USER_AGENT: ' + GetEnvironmentVariable(BROOK_CLT_ENV_HTTP_USER_AGENT) );
 WriteLn( 'BROOK_SRV_ENV_REMOTE_ADDR: ' + GetEnvironmentVariable(BROOK_SRV_ENV_REMOTE_ADDR) );
 WriteLn( 'BROOK_SRV_ENV_X_FORWARDED_FOR: ' + GetEnvironmentVariable(BROOK_SRV_ENV_X_FORWARDED_FOR) );

end;     

Solved ...
rgds
Ralph
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: RalphMuc on May 08, 2014, 11:04:43 pm
Hi,

the FastCGI sample source code is here : https://github.com/rbmuc/EasyBBS

Ralph
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: RalphMuc on May 10, 2014, 06:28:45 pm
Hi,

i build a installable version of Apache 2.4.9 x86  ( with openssl 1.0.1g and FastCGI ) support.
download https://bergertime.eu/download/httpd-2.4.9-win32-x86-openssl-1.0.1g.exe (https://bergertime.eu/download/httpd-2.4.9-win32-x86-openssl-1.0.1g.exe)
docu_en https://bergertime.eu/download/apache_fcgi_en.pdf (https://bergertime.eu/download/apache_fcgi_en.pdf)
docu_de https://bergertime.eu/download/apache_fcgi.pdf (https://bergertime.eu/download/apache_fcgi.pdf)

Ralph

Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: cahaya on December 12, 2014, 06:41:57 pm
Hi all,

I just check mod_proxy_fcgi, it work for lazarus with minor bugs(don't know bug or not).
Here my steps :

1. install apache 2.4 (just copy in windows)
2. enable LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so and
    LoadModule proxy_module modules/mod_proxy.so in httpd.conf.
    You can find file httpd.conf in directory conf.
3. add a new line ProxyPass /fcgi-bin/ fcgi://localhost:9000/ in httpd.conf
    /fcgi-bin/ is a directory I put under htdocs, you can put anywhere as long
    as you set permission.
4. add ScriptAlias /fcgi-bin/ "${SRVROOT}/htdocs/fcgi-bin/" under
    alias_module section.
5. add permission
    <Directory "${SRVROOT}/htdocs/fcgi-bin">
    AllowOverride None
    Options None
    Require all granted
   </Directory>

run your program fcgi. Don't forget to add Application.port := 9000;
uses
  fpFCGI, Main;

begin
  Application.Title:='FpCgi';
  Application.Initialize;
  Application.port := 9000;
  Application.Run;
end.
Please notice unit fpFCGI not fpCGI.

You can not use actio, something like /fcgi-bin/helloword.exe/testaction. In cgi action testaction is recognized by both. But in proxy, it seem apache do not compatible with that feature.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: chain_reaction on November 06, 2015, 05:22:12 am
Hello everyone, just to confirm that fp-cgi also works perfectly on lighttpd.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: DarkEagle on May 28, 2016, 07:34:55 pm
i'm finding on many web , so this thread can help me. thank you very much  ;D
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: egsuh on March 24, 2017, 06:47:58 am
Hello,

I've done a few web projects successfully with Delphi on IIS, both CGI and ISAPI.
I found Lazarus recently, and checking feasibility of web application with Lazarus.
I found that fpweb in Lazarus supports CGI and FastCGI. I've tested them on IIS, and found CGI works fine, but FastCGI doesn't work as expected.
I tried to run it on IIS7 (Windows 7) like as follows:

   http://localhost/fcgi/fcgiproject2.exe


but the response is:

    The application encountered the following error:
    Error: Could not determine HTTP module for request "fcgi"
    Stack trace:
    $0000000100036793
    $000000010003685B
    $0000000100036522
    $0000000100036D8F
    $0000000100035FEF
    $000000010003715F
    $0000000100038365
    $0000000100001847 line 16 of fcgiproject2.lpr
     ......................

Interesting point is that "fcgi" is just a folder name, as the executable file path is  c:\inetpub\wwwroot\fcgi\fcgiproject2.exe.  As "c:\inetpub\wwwroot" is the home directory for localhost, specifying "localhost/fcgi" works fine for other types of files. 

I have tested Apache server too, but the results are the same. I think there are some issue related with pathinfo of other thinks as fcgi is not read as a folder name.

If any of you have solved the same problem, please let me know. I would really appreciate.

Regards,

Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: mobilevil on August 16, 2017, 05:17:01 am
hello,
edit: I thought 1.8 RC4 was broken but I was wrong. with 1.8 RC4, the FPC version is updated to 3.0.4 RC1, in which the fp-web package is updated to support routing.
to enable legacy routing to fix my stupid hello world FCGI applicaiton,  add this to the main program.

Application.LegacyRouting:=true;


just to report that mod_fastcgi from mod_fastcgi-2.4.7.1-2.4.x-x64-vc14.zip, https://www.apachehaus.net/modules/mod_fastcgi/ is working for me, default and custom actions are fine.

both FastCgiServer and FastCgiExternalServer are working, but note that only the external config need the port setup line in the FCGI project
  Application.Port:=9999; // For example     

The FastCgiExternalServer mode is really good for debugging, and under windows the FCGI exe won't be locked by anyone so you can kill it anytime you like. You can debug, modify the code and build as you wish.

I am using apache 2.4 64 bit, httpd-2.4.27-x64-vc14.zip

this is my apache config

LoadModule fastcgi_module "modules/mod_fastcgi.so"
<IfModule mod_fastcgi.c>
  <Directory "C:/checkout/testfcgi/lib/x86_64-win64">
    #this two is for 2.2 only
    #Order allow,deny
    #Allow from all
    #this line is needed for 2.4
    Require all granted
  </Directory>
  #regular fast cgi, CGI exe itself is always loaded by apache, non-debuggable, for production
#  FastCgiServer "C:/checkout/testfcgi/lib/x86_64-win64/testfcgi.exe" -idle-timeout 30

  #external server fast cgi, debuggable, have to start the cgi program manually
  FastCgiExternalServer "C:/checkout/testfcgi/lib/x86_64-win64/testfcgi.exe" -host 127.0.0.1:9999 -idle-timeout 30 -flush
  ScriptAlias /myfcgi "C:/checkout/testfcgi/lib/x86_64-win64/testfcgi.exe"
</IfModule>
--------------------------------------
and here's my FCGI prrogram's main
begin
  Application.Title:='fcgiproject1';
  { Uncomment the port setting here if you want to run the
    FastCGI application stand-alone (e.g. for NGINX) }
  Application.Port:=9999; // For example
  Application.Initialize;
  Application.Run;
end.     


procedure TFPWebModule1.helloRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; Var Handled: Boolean);
var
  i:integer;
begin
  AResponse.contents.Add(datetimetostr(now)+' Hello world fast cgi with external server!<br>');
  AResponse.contents.Add(ARequest.URL+'<br>');
  for i:=0 to ARequest.FieldCount-1 do
  begin
    AResponse.contents.Add(ARequest.FieldNames + ' ' + ARequest.FieldValues+sLineBreak);
  end;
  Handled:=true;
end;

procedure TFPWebModule1.TFPWebAction0Request(Sender: TObject;
  ARequest: TRequest; AResponse: TResponse; Var Handled: Boolean);
var
  i:integer;
begin
  AResponse.contents.Add(datetimetostr(now)+' default action with external server!<br>');
  AResponse.contents.Add(ARequest.URL+'<br>');
  for i:=0 to ARequest.FieldCount-1 do
  begin
    AResponse.contents.Add(ARequest.FieldNames + ' ' + ARequest.FieldValues+sLineBreak);
  end;
  Handled:=true;
end;

initialization
  RegisterHTTPModule('TFPWebModule1', TFPWebModule1);
end.
             


Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: sfischer on August 05, 2018, 04:28:42 pm
Hi,
I try to get example program fcl-web/examples/helloworld running with lighttpd as webserver on raspian.
an excerpt of my /etc/lighttpd/lighttpd.conf looks like:

fastcgi.debug = 1
fastcgi.server = (
    "/helloworld" => (
      "helloworld.fcgi.handler" => (
        "socket" => "/tmp/helloworld.socket",
        "check-local" => "disable",
# "host" => "127.0.0.1",
# "port" => "2015",
        "bin-path" => "/var/lib/BASIS/pump/www/cgi-bin/helloworld",
        "max-procs" => 1
      )
    )
)

can someone supply a small manual, ho to get this working
thanks,
SF
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 10, 2020, 04:35:07 pm
I want to test my fast CGI.
I have created a VirtualHost to use 2015 port.

I get always this error for a long time, on Debian Buster and Ubuntu 20 :

Exception at 000000000048DE0B: EFPWebError:
Failed to bind to port 2015. Socket Error: 98.

The config is here :

<VirtualHost *:2015>
<Directory /var/www/cgi-bin>
Options All
AllowOverride All
Require all granted
Options +ExecCGI +FollowSymLinks

   SetHandler fcgid-script
   AddHandler fcgid-script .cgi
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

Listen 2015

ScriptAlias /cgi-bin "/var/www/cgi-bin"
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: mobilevil on December 11, 2020, 04:44:09 pm
quick google and a random guess
https://stackoverflow.com/questions/17780291/python-socket-error-errno-98-address-already-in-use

address is already in use, since it is not a well known port, I guess it is not something else that is using it. I GUESS you have a looping config file so that apache is trying to bind the same port twice. or something similar
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 11, 2020, 05:29:14 pm
After and only after starting a fcgi script i get this :
netstat | grep 9000
tcp6       0      0 127.0.0.1:9000          127.0.0.1:58058         TIME_WAIT
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: mobilevil on December 12, 2020, 03:06:50 pm
OK I was wrong. The bind error came from FCGI, not APACHE.
Apache should use it's own port, and FCGI use another.
e.g. Apache should use the default port 80, and FCGI's port is defined in both FCGI's main, and apache's config

see my post a few post above dated 2017.
look for FastCgiExternalServer and application.port
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 12, 2020, 03:08:47 pm
FastCgiExternalServer command is not recognized.

I use 2015 port in my Fast CGI. I use Listen command.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: mobilevil on December 12, 2020, 03:37:32 pm
are you using apache? which OS?
focus on port HTTP port 80 first.

the listen directive define the port apache use to talk to browser. not FCGI. usually the listen directive is already defined in the default config. both 80 for HTTP and 443 for HTTPS.

the FastCgiExternalServer directive is inside <IfModule mod_fastcgi.c> block, which is only valid if
LoadModule fastcgi_module "modules/mod_fastcgi.so" is also defined.
FastCgiExternalServer tell apache to use the specified port number to talk to the FCGI program.

browser -> port 80 -> apache -> port 2015 -> FCGI

so apache "listen" to port 80, and FCGI "listen" to port 2015.


Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 12, 2020, 04:59:00 pm
I use this config :
LoadModule fastcgi_module "/usr/lib/apache2/modules/mod_fastcgi.so"

<Directory /var/www/cgi-bin>
Options All
AllowOverride All
Require all granted
Options +ExecCGI +FollowSymLinks

   SetHandler fcgid-script
   AddHandler fcgid-script .cgi
    Order allow,deny
    Allow from all
</Directory>

FastCgiExternalServer "/var/www/cgi-bin/cgi2015.cgi" -host 127.0.0.1:2015 -idle-timeout 30 -flush

ScriptAlias /cgi-bin "/var/www/cgi-bin"

I got that it is unable to connect. After it has no header. But i have created a response.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 12, 2020, 05:01:58 pm
Here is the main unit :

program fcgihellow;

{$mode objfpc}{$H+}

uses
  fpFCGI, u_hellofcgi;

begin
  Application.Title:='fcgihellow';
  { Uncomment the port setting here if you want to run the
    FastCGI application stand-alone (e.g. for NGINX) }
  Application.Port:=2015; // For example
  Application.Initialize;
  Application.Run;
end.
               

Here is the web module :

unit u_hellofcgi;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, Classes, httpdefs, fpHTTP, fpWeb;

type

  { TFPWebModule1 }

  TFPWebModule1 = class(TFPWebModule)
    procedure DataModuleRequest(Sender: TObject; ARequest: TRequest;
      AResponse: TResponse; var Handled: Boolean);
  private

  public

  end;

var
  FPWebModule1: TFPWebModule1;

implementation

{$R *.lfm}

{ TFPWebModule1 }

procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
var
  LName: String;
begin
  LName := ARequest.QueryFields.Values['Name'];
  if LName = EmptyStr then
    with AResponse.Contents do
    begin
      Add('<form action="' + ARequest.URI + '" method="GET"');
      Add('<label for="name">Please tell me your name:</label>');
      Add('<input type="text" name="name" id="name" />');
      Add('<input type="submit" value="Send" />');
      Add('</form>');
    end
  else
    AResponse.Content := 'Hello World, ' + LName + '!';
  Handled := true;
end;

initialization
  RegisterHTTPModule('TFPWebModule1', TFPWebModule1);
end.     
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 13, 2020, 03:19:16 pm
iptables and ufw accept entering sockets.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 13, 2020, 06:24:11 pm
I reinstalled apache2. There is always the error.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: zamronypj on December 13, 2020, 11:46:13 pm
you should inspect error from apache error log to find what is wrong.

if you use Apache mod_proxy_fcgi, you can setup virtual host using ProxyPassMatch as follows
Code: XML  [Select][+][-]
  1. <VirtualHost *:80>
  2.      ServerName www.example.com
  3.      DocumentRoot /path/to/app/public
  4.  
  5.      <Directory "/path/to/app/public">
  6.          Options +ExecCGI
  7.          AllowOverride FileInfo
  8.          Require all granted
  9.      </Directory>
  10.  
  11.     ProxyRequests Off
  12.     ProxyPassMatch /(css|images|js).* !
  13.     ProxyPassMatch ^/(.*)$ fcgi://127.0.0.1:2015
  14. </VirtualHost>
  15.  

mod_proxy_fcgi is built-in module since Apache 2.4, you just need to enable it. For example on Debian Linux

Code: Bash  [Select][+][-]
  1. $ sudo a2enmod proxy_fcgi
  2.  

Code: XML  [Select][+][-]
  1.     ProxyRequests Off
  2.     ProxyPassMatch /(css|images|js).* !
  3.     ProxyPassMatch ^/(.*)$ fcgi://127.0.0.1:2015
  4.  

First line turn off forward proxy. Second line tells Apache to serve any files from css, images or js directory in document root directly. Third line tells Apache to pass everything else to application listen on 127.0.0.1 port 2015. "fcgi:" tells mod_proxy to use mod_proxy_fcgi.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 14, 2020, 07:42:14 pm
Thanks for reply !

I got always the same error :
[Mon Dec 14 19:40:33.894880 2020] [proxy:error] [pid 10109:tid 140072876771072] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:2015 (127.0.0.1) failed
[Mon Dec 14 19:40:33.894975 2020] [proxy_fcgi:error] [pid 10109:tid 140072876771072] [client 127.0.0.1:52044] AH01079: failed to make connection to backend: 127.0.0.1

I use Lazarus 2.0.10
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: zamronypj on December 15, 2020, 12:34:46 am
You need to check if


To check if application listen on correct port

Code: Bash  [Select][+][-]
  1. $ netstat -tunlp | grep 127.0.0.1:2015
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 15, 2020, 01:05:27 pm
No result.

Must i keep FastCgiExternalServer ?
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: cappe on December 15, 2020, 04:25:28 pm
but if you write like this something comes back

    $ netstat -tunlp | grep 2015
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 15, 2020, 05:16:34 pm
No result too.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: zamronypj on December 16, 2020, 02:34:52 am
If netstat command above shows no result, it means your application is not running. That is why Apache cannot connect to your application. You need to run application first.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: egsuh on December 16, 2020, 03:52:11 am
I have no experience with Apache, and I can run FCGI modules on IIS - Windows 10 successfully.

Logically thinking, IIS runs FCGI program so I do not assign separate port -- I think the same applies to Apache. Separate port is necessary to run it as HTTP server, which responses directly, not via IIS or Apache. 

First, test with following main program.

Code: Pascal  [Select][+][-]
  1. begin
  2.    Application.Title:='fcgihellow';
  3.   { Uncomment the port setting here if you want to run the
  4.     FastCGI application stand-alone (e.g. for NGINX) }
  5.   // Application.Port:=2015; // For example
  6.  
  7.    LegacyRouting:= True;
  8.    Application.Initialize;
  9.    Application.Run;
  10. end.
  11.  

In IIS, I have to set Handler Mappings --- I have to add mapping for the application program. Don't know how to do this in Apache.

Important thing is that allowPathInfo should be set TRUE. Again, no idea whether this is applicable to Apache.

But as I posted in other posts, Free Pascal fCGI model is not perfect --- I believe it has some problem in memory management. (the author acknowledges this). 

Anyway please let me know your result. I'd like to have as many developers of Lazarus webserver as possible.^^
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on December 16, 2020, 12:57:19 pm
I have deleted link to fastcgi module.

It does always no result.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on August 25, 2021, 04:06:49 pm
I install alibaba TENGINE for NGINX.

It seems well done.

There is FastCGI module but to let Fast CGI working i need to use fcgi wrapper.

How can i do ? I have 502 bad gateway error.

My config :
server {
 
        listen       80;
        server_name  localhost;
        access_log  /var/log/nginx/fastcgi.access.log;
 
        index index.html index.php index.html;
        root /var/www;
 
        location /cgi
        {
 
        }
 
        location ~ \.fcgi$
        {
            include fastcgi_params;
#           fastcgi_pass unix:/var/run/fcgi.sock;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index  hellow.fcgi;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;
        }
}
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: nicanor on October 04, 2021, 12:50:07 pm
Hi

I found this page showing information about to configure nginx and fastcgi: https://difyel.com/nginx/how-to-setup-nginx-with-cgi-fastcgi-and-c-bash-lisp-or-any-other-programming-language-on-debian-and-freebsd/index.html

In the first example the autor shows how to set nginx whit a fastcgi wrapper to CGI. And second he shows how to use a fastcgi server with nginx .... (Well, at least, it was i understood... Sorry, I'm completely newbie in this area, and just learning)

Unfortunately I have no success applying the second way in my local machine whit ubuntu. Hope this may be useful for you!

Cheers
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: nicanor on October 04, 2021, 01:06:55 pm
By the way, if you were to start developing a new web application today... And wanted to use lazarus/fpc... As a matter of fact, you could tell me if the way is still to create fastcgi application, or is there some other way. It's just because I'm new even in this web area, sorry
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: egsuh on October 04, 2021, 01:18:57 pm
I have successfully tested NGINX with free pascal FastCGI.  Please refer to following thread.

https://forum.lazarus.freepascal.org/index.php/topic,56583.msg420471.html#msg420471 (https://forum.lazarus.freepascal.org/index.php/topic,56583.msg420471.html#msg420471)

I experienced some problems with FastCGI with MS IIS, but this problem does not happen with NGINX.

@nicanor,

I do not have a wide experience but Lazarus/FPC is quite useful tool to develop web server application, based on my experience. I have set up a survey platform, and doing surveys with it.
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: fblu on November 19, 2021, 01:14:08 pm
By the way, if you were to start developing a new web application today... And wanted to use lazarus/fpc... As a matter of fact, you could tell me if the way is still to create fastcgi application, or is there some other way. It's just because I'm new even in this web area, sorry
I'm not much of a webdev either, but if  you want to create a REST API and want to use fpc, you can use Horse ( https://github.com/HashLoad/horse ).
Title: Re: FCGI (FastCGI) step by step, using fpweb/fcl-web for Windows/Linux
Post by: matthius on April 27, 2022, 12:16:41 pm
On 2021, there is a Fast CGI development kit called fcgi2 :
http://fastcgi-archives.github.io/fcgi2/doc/fcgi-devel-kit.htm (http://fastcgi-archives.github.io/fcgi2/doc/fcgi-devel-kit.htm)

But they are very poor in examples which not exists as in documentation.

I do not know how to use it on 2022-04. For example, we don't see any link to a fastcgi in html pages.
TinyPortal © 2005-2018