我会升级到Linux的 Debian 6.0 "Squeeze" 即将在服务器上,我想知道我可以使用的Python 作为专用于不同的事情很多端口的Web服务器。

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.

这意味着,端口443可被用于许多网站(搭载了相同的代码只是在SQL DB不同势)

有帮助吗?

解决方案 2

在蟒:

import os
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

class myHandler(BaseHTTPRequestHandler):

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

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

if __name__ == "__main__":
    main()

其他提示

这不是一个问题PHP作为PHP解释不对端口直接听。在Linux上,这将(通常)内运行Apache。 Apache可以被配置为监听到多个端口,并且即使是在每个虚拟主机基础。

此外,要知道,HTTPS的特性使它不可能对多个虚拟主机使用自己的SSL证书,并仍然是所有侦听同一端口上。他们将每个人都需要自己的证书,需要倾听自己的端口上。

此外,发送特定的端口设备上运行的虚拟机是无关的Web服务器,更不用说执行环境。这是配置所述虚拟网络内的端口转发的混合,在虚拟机中加上本地web服务器配置。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top