* DRAFT *




==========================================================================

libapache2-mod-fcgid

==========================================================================



sudo apt-get install libfcgi-dev

sudo apt-get install libapache2-mod-fcgid


a2enmod fcgid


mkdir exemple_mod-fcgid

cd exemple_mod-fcgid



ref : https://opensource.apple.com/source/FastCGI/FastCGI-4/fcgi/doc/fcgi-devel-kit.htm#S3.1


nano tiny-cgi.c


-----------


    #include <stdio.h>

    #include <stdlib.h>


    void main(void)

    {

        int count = 0;

        printf("Content-type: text/html\r\n"

               "\r\n"

               "<title>CGI Hello!</title>"

               "<h1>CGI Hello!</h1>"

               "Request number %d running on host <i>%s</i>\n",

               ++count, getenv("SERVER_NAME"));

    }


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



nano tiny-fcgi.c

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


    #include "fcgi_stdio.h"

    #include <stdlib.h>


    void main(void)

    {

        int count = 0;

        while(FCGI_Accept() >= 0)

            printf("Content-type: text/html\r\n"

                   "\r\n"

                   "<title>FastCGI Hello!</title>"

                   "<h1>FastCGI Hello!</h1>"

                   "Request number %d running on host <i>%s</i>\n",

                    ++count, getenv("SERVER_NAME"));

    }


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


gcc tiny-cgi.c -o tiny-cgi

gcc -I/usr/local/include tiny-fcgi.c -lfcgi -o tiny-fcgi


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


test en ligne de commande :

./tiny-cgi

./tiny-fcgi


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


cd /etc/apache2/conf-enabled

sudo nano my_fcgid.conf


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

User www-data

#Listen 8080

PidFile apache.pid

DocumentRoot .

LoadModule fcgid_module /usr/lib/apache2/modules/mod_fcgid.so

SetHandler fcgid-script

Options +ExecCGI

ErrorLog error.log



*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=


ATTENTION : 

===========


Si je mets le  my_fcgid.conf alors, les cgi normaux ne fonctionnent plus :


avant : http://192.168.90.174:8080/cgi-bin/tiny-cgi => OK

après : http://192.168.90.174:8080/cgi-bin/tiny-cgi => Internal Server Error


Mais : http://192.168.90.174:8080/cgi-bin/tiny-fcgi => OK et compte correctement


Si je retire le my_fcgid.conf :


sudo mv my_fcgid.conf my_fcgid.xonf

mirtos@MirTOS-server:/etc/apache2/conf-enabled$ systemctl restart apache2



http://192.168.90.174:8080/cgi-bin/tiny-cgi => OK

http://192.168.90.174:8080/cgi-bin/tiny-fcgi => OK MAIS ne compte pas ! Donc un CGI normal !


pourtant : 

sudo -u www-data /usr/lib/cgi-bin/tiny-cgi

comme si le my_fcgid.conf rendait non executable le serve-cgi-bin.conf poutant le repertoire est bon

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=


MODIFICATION ----->

ref : https://httpd.apache.org/docs/current/fr/handler.html

ref : https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#examples ---> Configuration directives



sudo nano my_fcgid.conf

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

<IfModule mod_fcgid.c>

  FcgidConnectTimeout 20


  ScriptAlias /fcgi/ /usr/lib/cgi-bin/fcgi/

  <Directory "/usr/lib/cgi-bin/fcgi">

    SetHandler fcgid-script

    Options +ExecCGI

  </Directory>


</IfModule>

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



http://192.168.90.174:8080/cgi-bin/tiny-cgi

=> OK

http://192.168.90.174:8080/fcgi/tiny-fcgi

=> OK 


*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=



MirTOSface en ModCGI 


Un version adaptée de MirTOSFace compatible ModCGI est disponible sous le nom de MTf


La compilation se fait en ajoutant le define 

-DUSE_FAST_CGI


g++ -Ofast -Wall -I/usr/include/libxml2 -DUSE_FAST_CGI MTf.cpp lib_netsockets/socket.o lib_netsockets/ftp.o MirQueue.o Evaluator.o MirTOS_Event.o Regexp.o TinyXML.o MirXML.o MirIni.o -o MTf  -lfcgi -lmosquitto -lsqlite3 -lxml2 -lxslt 



On prendra soin de modifier le config.ini (call_me et app_name) :


[General]

_log_path=/home/mirtos/MirTOS/log

log_path=/var/log/mirtos

startup_wait=5

mqtt_host=localhost

mqtt_port=10883

_db_filename=/home/mirtos/MirTOS/db/MirTOS.db

db_filename=./MirTOS.db

backup_path=/home/mirtos/MirTOS/backup

debug_path=/var/log


[Face]

app_name=MTf

call_me=/fcgi/MTf

xsl_path=/home/mirtos/MirTOS/xsl

xsl_default=default.xsl


default.xsl=D+V+P


[Domains]

xml_path=/home/mirtos/MirTOS/xml



REM : Les fichiers xml / xsl / db / bckup / log doivent être accessible, ce qui pose des problèmes si les fichiers sont sous le user mirtos.

La solution temporaire :

sudo chmod u+s /usr/lib/cgi-bin/fcgi/MTf



 






Créé avec HelpNDoc Personal Edition: Créer des fichiers d'aide Qt Help multi-plateformes