You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.4 Common gateway 2.0KB

So far you have

  • setup XAMPP
  • read up on
    1. Web servers, browsers,
    2. the HTTP
    3. and URIs

Now we are at the point where programming comes into play - a web browser loading a “web app”, a program, if you will.

Remember how we went over programs (in document 1.1) and applications (in document 1.3)? This is now transferrable to web apps. If you re-visit 1.3 you will find documented very basic usage of the “dir” program, whose purpose is to list out state of the filesystem (see documents 3.1, 3.2) at location which it is invoked from.

Well, this same functionality can be turned into a web app, an HTTP networked program. You could, if you wanted to, tell Apache (in your XAMPP installation) to run “dir” every time it gets an HTTP request.

You could, if you wanted to, write a C++ “hello world” program

#include <iostream>

int main()
        std::cout << "Hello world!";
        return 0;

then point your XAMPP apache to the compiled binary/runtime so once you load http://localhost in a browser you will see a page saying “Hello world!”. Now you get how web development basically works: write a program/script, then point a web server to get said program’s output.


CGI script setup

To elaborate more on the “then point your XAMPP apache to XYZ” part, if you get variability and how programs/functions work in general (see documents 1.4, 1.5), you will understand that what happens at server run-time is that the




directory (whichever one you are operating on (depending on the OS)) is basically a parameter, instructing the server program to ask the filesystem for data stored in that directory. In our previous case it was an index.html file within /var/www/html (or the other one), for the rest of this project and as we are dealing with PHP, the data that we are initially giving the web server will be an index.php script/file - instructing the server to pass the script/file contents to a PHP-interpreting program (usually php-fpm (on older setups php-cgi)).