How To Get Gambas Web Started (1)


Below is a brief information on how to start and use a Gambas web site, the requirements and how to deploy the work done. Note that the testing of the web page inside the IDE is not the same as when it is called from the browser, because the IDE, when executed, uses its own embedded web server with different variables (very different) respect a production server, and different from the interpreted code.

Use the directory of the project as the program to compile it and embed it in the "real" web server.

A gambas web (CGI) program is very simple to made, i just a piece of code like this:

Public Sub Main()
    Print "<h1>hola mundo</h1>"

But this don't handle client requests (Request class) just a simple static "hola mundo" using the Response class to the web browser when client (user) request the CGI program code compiled.

Illustrating the equivalents

The Gambas technology offers the same characteristics and featured in similar way as other technologies, let's see a comparison table of this:


Interpreted Compiled
Gambas gbs files (Gambas server pages) gb programs (Gambas web component)
Java jsp (Javas server pages) servlets (Java Enterprise)
PhP php/phtml (php-cgi/php-fpm) N/A
.NET asp (active server pages) COM ( CLR runtime)

Preliminary concepts

Gambas web technology is provided to produce web 2.0 ( dynamic and also interactive content).

There are two ways to produce and/or render html in dynamic or static web content: Interpreted and/or pre Compiled.

The web content is produced with the help of a web server, using always CGI, directly announcing the pre Compiled program or as wrapper to the Gambas interpreter through script code.

Independently of the way the server delivers the document web page, all the time the CGI concept is used.

What its CGI?: Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs like console applications (also called command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The server determines how the script is executed by the server.

Interpreted (as script) (Gambas server pages) permits interpret a source files and based on their content as script will render html or not using logic, its only recommended for static content that only need minimal logic, when fails show the source code in webserver, this must be configure using the cgi as wrapper that deliver the request to interpreter.
Precompiled (as cgi) (Gambas web component) permits compiling the program that will be acts as cgi program and produces the html rendering. The ide component was given due install many of the necessary, but in server its not recommended, this must be configured as the handler of the request directly.


We need a web server, a Gambas IDE compiler and Gambas script interpreter, unless you only make cgi's the scripter are unnecessary. The recommended install command must be done open a console and switching to root to install the Gambas distribution program packages, the required web server packages and setup the cgi components in the web server.

Installation requirements

First: get Gambas! The easiest way is to install Gambas from your Linux distribution. If Gambas is not yet contained in your distribution then download the distribution from

Second: understanding! Need understand REALLY the concepts of request Request and response Response, here it is required to be familiar, HTTP is based on a request / response model, so there are two types of HTTP messages: the request and the response. The browser opens a connection to a server and makes a request. The server processes the client "makes a request" and webserver "returns a response"; so then data its send and received using the two most commonly HTTP methods: GET and POST. Due Gambas its a RAD(Rapid Application Development) those concepts must be very clear for developer.

Last: get environment! Need a webserver, that provides true gci capabilities. Nginx does not provide real capabilities u will need further tuneup to property configure it. As general further info for high end production environments, that must configure as a duple of a server front end that provides a proxy reverse to the real cgi webserver with the Gambas3 cgi program.

Feature Comparison Chart and Status

Start to develop in Gambas need a right direction point, so we provide a quick chart to see supported features respect other technologies.

The development of web technologies has gained strength from about 3 years ago in the Gambas community developers, having today even a fully web graphical design component.

Here are not included the leaning curve because learn Basic its obviously more easy rather any other programing language, and Gambas are Basic like!

A performance comparison mail (January 2020) at the mail list; demonstrating how Gambas performs as well or better as php with interesting results.


Gambas Java .NET Python Php
Based Coding Language Basic C++,C Basic,C++ CPython,C Perl,C
Backguard coding compatible always always Breaking API each 4 years Incompatible always
Running On Unix based Any OS Only MS based Almost Any OS Almost Any OS
Web server Any cgi based Tomcat, Jboss, Glassfish, Websphere, Weblogic IIS Apache2, IIS, Lightty, Hiawatta,Ngynx Apache2, IIS, Lightty, Hiawatta,Ngynx
Runtime Gambas Runtime Java virtual Machine Common Languaje Runtime Python runtime Zend Engine
Graphical Designer Gambas IDE Eclipse thirparty .NET IDE Not Not
Web Components gb.web, gb.http, gb.web.feed, gb.util.web, gb.curl EJB, JSP, JSF, Spring, GWT ASP, Spring, COM Many php-cgi, php-fpm, php-curl, php-sockets, more..
Web frameworks Gambasforge Spring, Struts, GWT Buil-in Django,CubicWeb Codeigniter, Lavarel, Symphony
DBMS Data Access ODBC, MySQL, SqLite, Postgres JDBC: Oracle, Sybase, MSSQL, MySQL, Sqlite, DB2, etc ADO.NET-oleDB, ODBC PyODBC: ODBC php-odbc, Php-pysql, php-sybase, php-pgsql, php-sqlite
DBMS Data Mapping Jbsan MapBD Hibernate, Dozer, Commons, Mapstruts, ModelMapper ADO.NET Django, Pandas Codeigniter, Kohana, Doctrine
Web services gb.xml Build-in Buil-in Add-on (many) php-soap, php-xml
Mobile native not yet Androit SDK Xamarin(MOno) Kivy, BeeWare Not possible
Unit Tests By own JUnit NUnit,MSUTF PyUnit PhpUnit

Starting coding

Gambas its a RAD software so lest assume will use the IDE, due you can always also use a normal text editor and then compile the cgi program by hand in console.

Start to code in IDE

When finished the installation then use Gambas:

  • In a terminal window type "gambas3.gambas"

  • The Gambas IDE will open, select "New project...".

  • Select "Create a application web gb.web", click next,

  • Find a directory where to put the web project, click next,.

  • Enter a name for your web project, click OK.

  • Close the tips of the day window.

This start a main module that when build renders a page that prints important values, need to understand to manage web cgi's,

  • In the project window find the start button, press it (or press F5 key).

  • Then for a while, the default browser will opened or a new tab will raise and a web address from localhost will be displayed

this starts a local embedded webserver using a bind port 8080, displaying the server GCI standard values, those are very important to understand for high level production web pages.

Deploy the results

The IDE when runs its a local embedded server, this are significant different rather runs on the server due u must specify what its the "entry point" of the web application.

As a path root: the cgi will processed all the path from root, example: http://domain/thegcipath/ As a entry web: the cgi will be called directly by the request, example: http://domain/thegcipath/thecgiprogram

1) configuring CGI in webserver

On standard web server of providers web servers there's only two paths where the "produced program" (the Gambas compiled program u make) can be deployed, in the "/cgi-bin/" web path, and there's two only places for them, globally and per users, there's configurations for both cases:


Initial/global configs Per user configs Script additions module related
apache ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AddHandler cgi-script .cgi .sh .pl Options ExecCGI SetHandler cgi-script AddHandler cgi-script .gbs () a2enmod cgi cgid alias userdir
lighttpd $HTTP =~ "^/cgi-bin/" { cgi.assign = ( "" => "" ) } $HTTP =~ "^(/~[^/]+)?/cgi-bin/" { cgi.assign = ("" => "") } cgi.assign = ("gbs" => "gbs3") lighty-enable-mod cgi alias userdir

() in apache there's still no way to workaround the interpreting of the scrips at the moment of writing this

2) Producing an deploying in webserver

  • In the IDE, go to 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 programs 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.

See also