I'll improving to Linux Debian 6.0 "Squeeze" around the server soon and I wish to understand how I'm able to use Python like a web-server on many ports devoted for various things..

Ports            Directory           Description
80, 443          /var/www/sitegen/   Take all domains and generate a site from the SQL DB
444, 1000-3000   /var/www/manager/   Take 444 as a PHP server manager and the rest to be forwarded to serial hardware.
8000-9000        The VMs DIR         Forward the port to port 80 (or 443 by settings) on the VMs.

Which means that the main harbour 443 might be employed for many sites (run by exactly the same code just diffrent within the SQL DB)

This is not a PHP question because the PHP interpreter does not directly listen on ports. On Linux, it'll (usually) run inside Apache. Apache could be set up to hear multiple ports, as well as on the per-virtual host basis.

Also, remember that the character of HTTPS causes it to be impossible for multiple virtual hosts to make use of their very own SSL certificate but still all listen on a single port. They'll each need their very own certificate and want to pay attention by themselves port.

Additionally, delivering specific ports to virtual machines running around the box is certainly not related to the net server, not to mention the execution atmosphere. This can be a mixture of setting up the main harbour sending within the virtual network, combined with local web server configuration inside your virtual machines.

In python:

import os
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

class myHandler(BaseHTTPRequestHandler):

    def do_GET(self):
        self.send_header("Content-type", "text/html")
        self.wfile.write("This is working")

def main():
        server = HTTPServer(("", 8080), myHandler)
        print "Sever is up.."
    except KeyboardInterrupt:
        print "Bye, Bye!"

if __name__ == "__main__":