INDEX:
0) Introduction
1) Software requirements
2) Webserver configurations combinations
3) Deployments and testing the web program
0) Introduction/Introduccion:
Please read before: http://qgqlochekone.blogspot.com/2017/03/gambas-web-la-filosofia-web-vs-la.htmlEl programa generado gambas (el ejecutable que por lo general tiene extesion gambas) es en si un "escupidor de html", este es el que se invoca en el request y este emitira el response.
The gambas program generated (that exec by general have gambas extension) its per se an "html ouput renderer", that its the file called in the request and that emit the response.
From the IDE vs from the webserver! CUIDADO/BEWARE!
No es el mismo, cuidado! el IDE gambas ejecuta el codigo embebido en su propio wervidor http usando puerto 8080, el path server sera el directorio del proyecto, el server web root sera la raiz del url ... es decir corre un servidor web como si fuera entero para el proyecto! Cuando ud despliegue el cgi esto cambia radicalmente confundiendolo!
Not the same, beware! The gambas IDE run the embedded code on its own http web server using port 8080, the server path will be the application path, the server web root will be root of the server runnign from the url web browser as if the hole only for the project! When the CGI is deployed this radically changes confusing it the developer!
1) SOFTWARE REQUIREMENTS:
We need a webserver, a gambas ide compiler and gambas script interpreter, unless u only make cgi's the scripter are innecesary. The recomended install command must be done open a console and swichting to root:
Requeriment | Available | recomended and install command | explanation |
Webserver | apache2 lighttpd hiawatha | apt-get install lighttpd apache2.2-utils | provides the cgi andler and web interface to request to bypass to the cgi produced by gambas, webservers like nginx does not provide good cgi handler and its not supported, hiawatha its not recomended for production large deployments |
Compiler | gambas3-ide gambas3-runtime | apt-get instal gambas3-runtime gambas3-web gambas3-util-web gambas3-xml gambas3-xml-rcp | permits compiling the program tht will be acts as cgi program and produces the html rendering. The ide component was given due install many of the necesary, but in server its not recomended. |
Scripter | gambas3-scripter | apt-get install gambas3-scripter | permits interpret a source files and based on their content as script will render html or not using logic, its only recomended for static content that only need minimal logic, when fails show the source code in webserver |
2) SERVER GLOBAL CONFIGURATIONS
open consolegin root privilegies: su
run command: apt-get install
Requerimientos | paquete | valor inicial y ruta ejecutora | modulo |
apache | apache2.2-bin | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AddHandler cgi-script .cgi .sh .pl | a2enmod cgi |
lighttpd | lighttpd | $HTTP["url"] =~ "^/cgi-bin/" { cgi.assign = ( "" => "" ) } | lighty-enable-mod cgi |
hiawata | hiawatha | cgi | cgi |
2.1) Default configurations parameters
configuration by default let only /usr/lib/cgi to permits and as place for cgi scripts... keep reading to enalbe others or per user
Configuracion | apache2 | lighttpd | explicacion |
Solo los ejecutables | Options +ExecCGI | cgi.execute-x-only = "enable" | permite en donde lo coloques que cualquier cgi se ejecute, por defecto solo el directoro /cgi-bin/ los ejecuta y el htdocs /var/www/html |
Solo algunas extensiones | AddHandler cgi-script cgi gba | cgi.assign = ("gba" => "gba") Cgi.assign += ("cgi" => "cgi") | Si por alguna razon no funciona, cambia la extension a “cgi” o “gba” y con esta option los “separas” explicitamente a ejecutar |
2.2) User server configure cgi:
Configuracion | apache2 | lighttpd | explicacion |
Para el directorio web por usuarios ( ~user) |
Options ExecCGI
SetHandler cgi-scri
|
$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" {
cgi.assign = ("" => "")
}
| permite en donde lo coloques que cualquier cgi se ejecute, por defecto solo el directoro /cgi-bin/ los ejecuta |
Solo interpretar scripts | AddHandler cgi-script gba | cgi.assign = ("gba" => "gbs3") |
Solo interpretar los script no compilados, y que los ejecute el compilador/interprete gambas con el http server embebido, esto solo se hace para los archivos no compilados.
NOTA: no es seguro, si el script falla, el codigo es escupido al navegador!
|
..
3) DEPLOYMENT AND GIVE UP RESULTS
3.1) configuring CGI
Webserver | Initial/global configs | Per user configs | Script aditions | package related | module related |
---|---|---|---|---|---|
apache | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AddHandler cgi-script .cgi .sh .pl | AddHandler cgi-script .gbs () | apache2.2-bin | a2enmod cgi cgid alias userdir | |
lighttpd | $HTTP =~ "^/cgi-bin/" { cgi.assign = ( "" => "" ) } | $HTTP =~ "^(/~[^/]+)?/cgi-bin/" { cgi.assign = ("" => "") } | cgi.assign = ("gbs" => "gbs3") | lighttpd | lighty-enable-mod cgi alias userdir |
2) producing the program cgioose th
- In the ide, go to menu->project
- Create-> executable
- If u use the "per user configuration" choose the directory output as "public_html" under your home
- Choose the name of the output program, by default "programname.gambas"
- If the webserver only permits cgi's porgrams with .cgi extension put in second input: mv $(FILE) $(FILE).cgi
- The cgi program now can be invoked from url http://localhost/~username/cgi-bin/programname.gambas.cgi
All of this its taking in consideration that inside your home, there's a "public_html" directory, used and handled by the webserver as per user web content, and also under this there's a "cgi-bin" directory, that its for cgi programs, and the webservers software are only apache2 or lighttpd.
CONTINUARA....
Por favor, proporcione un ejemplo de aplicación web desarrollada en gambas.
ResponderBorrar