lighttpd+webpy安装实践

1)安装lighttpd

wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.30.tar.gz

./configure -prefix /opt/modules/lighttpd

make

make install

cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd

修改启动脚本:将第29行修改为:

lighttpd="/opt/modules/lighttpd/sbin/lighttpd"

chmod a+rx /etc/init.d/lighttpd

cp -R doc/config/conf.d /etc/lighttpd/

cp -R doc/config/vhosts.d/ /etc/lighttpd/

cp doc/config/*.conf /etc/lighttpd/

修改lighttpd配置文件:vi /etc/lighttpd/lighttpd.conf

var.basedir = "/var/www/localhost"

var.logdir = "/var/log/"

#载入一些要用到的模块

server.modules = (

"mod_access",

"mod_fastcgi",

"mod_rewrite",

"mod_accesslog",

)

server.document-root = "/opt/test"

server.pid-file = "/opt/test/lighttpd.pid"

server.errorlog = var.logdir + "/lighttpd-error.log"

server.port = 9001

accesslog.filename = var.logdir + "/lighttpd-access.log"

#fastcgi模块设置

Fastcgi.server = ( "/test.py" =>

( (

"socket"=>"/tmp/fastcgi-wen.socket",

"bin-path"=>"/opt/test/testpy",

"max-procs"=>2, #python子进程个数

"check-local"=>"disable", )))

#rewrite模块设置

url.rewrite-once = (

"^/(.*)$" => "/test.py/$1", #把所有请求重定向到hello.py

)

2)安装web.py

easy_install web.py

如果easy_install安装失败,也可以下载源代码包进行安装:

Python setup.py install

3)Hello world测试:

#!/usr/bin/env python

import web

urls = (

    '/(.*)', 'hello'

)

app = web.application(urls, globals())

class hello:       

    def GET(self, name):

        if not name:

            name = 'World'

        return 'Hello, ' + name + '!'

if __name__ == "__main__":

    app.run()

运行:python test.py

输出:http://0.0.0.0:8080/

打开其他窗口访问:curl http://0.0.0.0:8080/

如成功,则返回:hello world

修改脚本权限为:755

4)启动lighttpd/etc/init.d/lighttpd restart

查看错误日志,确保启动成功

5)curl http://0.0.0.0:9001/



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值