2013-02-13 50 views
0

我有一個Python腳本包含:如何從lighttpd的的mod_fastcgi轉換到Apache 2.2 mod_fcgid

from flup.server.fcgi import WSGIServer 

def processRequest(environ, start_response): 
    # proprietary business logic here 
    return 

WSGIServer(
    application = processRequest, 
    bindAddress = ('0.0.0.0', 6543), 
    umask = 0 
    ).run() 

我與Python 2.7.3一個Ubuntu 12.04.2 LTS服務器上運行命令行這個Python腳本。

在同一個服務器,我的lighttpd版本1.4.28配置了

server.modules = (
    "mod_access", 
    "mod_alias", 
    "mod_compress", 
    "mod_redirect", 
    "mod_setenv", 
    "mod_fastcgi", 
    "mod_accesslog" 
) 

$SERVER["socket"] == ":443" { 
    ssl.engine = "enable" 
    ssl.pemfile = "/etc/lighttpd/ssl/secret.pem" 
    server.document-root = "/var/www" 

    fastcgi.server = (
      "/MyFCGI/" => 
      ((
       "host" => "127.0.0.1", 
       "port" => 6543, 
       "check-local" => "disable" 
      )) 
    ) 
} 

當我要求https://TheEffKyouDeeEnn/MyFCGI/blah/blahblah與JSON對象POST,系統行爲我希望的方式,並通過經過我的要求到在命令行上運行的Python腳本。

我需要在運行Apache 2.2的MS-Windows Server計算機上配置相同的功能。我想保留在網絡上的任何位置部署我的Python腳本的能力,而不是僅在具有Apache實例的服務器上。雖然文檔似乎表明這是可能的,但至少使用mod_fcgid,我無法使它自己工作,也找不到一個工作示例。

你能否確認mod_fcgid是合適的模塊,並舉例說明如何配置Apache和mod_fcgid來複制我的lighttpd行爲?

+0

http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html有Apache配置的示例。也就是說,這個問題可能屬於ServerFault – JeffS 2013-02-13 22:03:04

回答

0

這複製了與Apache2.2相同的功能。

 

    LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so 
    LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so 

    VirtualHost *:80 

     DocumentRoot /var/www/ 

     Header set Access-Control-Allow-Origin "*" 
     Header set Access-Control-Allow-Headers "Content-type" 
     Header set Access-Control-Allow-Methods "POST,GET,OPTIONS" 

     AliasMatch ^/MyFCGI/.*$ /var/my_fcgi.py 

     Directory /MyFCGI/ 
      Options FollowSymLinks +ExecCGI 
      AllowOverride All 
      SetHandler fastcgi-script 
     /Directory 

     FastCgiExternalServer /var/my_fcgi.py -host localhost:6543 

    /VirtualHost