lighttpd使用fastcgi同时支持php和python
发表回复
我们前面已经谈到 用lighttpd的scgi模块部署webpy, 类似于nginx, ligthttpd同样可以使用fasctcgi同时支持php和python
在 /etc/lighttpd/lighttpd.conf 注释掉
#server.document-root = “/var/www”
#server.errorlog = “/var/log/lighttpd/error.log”
#server.username = “www-data”
#server.groupname = “www-dat
在/etc/lighttpd/conf-enabled 创建文件,或者符号链接 mobile.conf (注意要以 .conf结尾),内容如下
server.modules += ( "mod_fastcgi", "mod_accesslog", "mod_rewrite", ) server.document-root = "/home/carbon/stealth" server.errorlog = "/home/carbon/lighty/log/error.log" accesslog.filename = "/home/carbon/lighty/log/access.log" server.username = "carbon" server.groupname = "carbon" fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/home/carbon/lighty/fastcgi.php.socket", "max-procs" => 1, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )), "" => (( "socket" => "/home/carbon/lighty/fastcgi.python.socket", "bin-path" => "/home/carbon/stealth/t.py", "max-procs" => 1, "bin-environment" => ( "REAL_SCRIPT_NAME" => "" ), "check-local" => "disable" )), )
重启后lithttpd
在/home/carbon/stealth编辑如下文件 i.php
和 t.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import web web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr) urls = ( '/hello', 'hello') class hello: def GET(self): web.header("Content-Type","text/html; charset=utf-8") return "Hello world!" app = web.application(urls, globals()) if __name__ == "__main__": app.run()
用浏览器访问
http://localhost/i.php
和
http://localhost/hello