lighttpd支持python
2015-11-18 22:49
531 查看
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
相关文章推荐
- HttpDns
- python之迷你版Httpd服务器
- OkHttp解析系列-重定向和出错重试
- Linux基本网络命令
- 网络原因导致 npm 软件包 node-sass / gulp-sass 安装失败的处理办法
- 调度策略 http://book.2cto.com/201302/16285.html
- Linux进程调度概述 http://blog.sina.com.cn/s/blog_682686610100qqi3.html
- android:使用网络通信技术从客户端直接获取服务端的对象数据
- XMLHttpRequest对象的属性
- 数据库与MATLAB链接http://blog.sina.com.cn/s/blog_9d0b00a401012spy.html
- VirtualBox虚拟机网络设置(四种方式)
- 【转载】TCP数据包实例解析
- 【总结】【Unix网络编程】前言及基础知识
- webrtc 学习资源 http://www.cnblogs.com/lingyunhu/p/3578218.html
- XMLHttpRequest对象的方法
- TCP/IP四层模型
- 网络监测
- TCP的那些事
- 使用httperrequest,模拟发送及接收Json请求
- iOS网络构架 与 web服务器 (三次握手)