ubuntu下web.py加apache 实现简单服务器

做过的事如果不记下来很容易就忘了。。。还是应该养成记blog的习惯啊快哭了


安装 easy_install:

sudo apt-get install python-setuptools

安装web.py:

sudo easy_install web.py

安装apache服务器:

apt-get install apache2


安装mod-wsgi:

sudo apt-get install libapache2-mod-wsgi

编辑/etc/apache2/sites-available/default,在<VirtualHost *:80> 下加入:

  ServerName webapp.com
    DocumentRoot /home/webapp
    <Directory /home/webapp>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /home/webapp/static
    Alias /favicon.ico /home/webapp/static
    WSGIDaemonProcess webapp.com processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup webapp.com
    WSGIScriptAlias / /home/webapp/index.py


然后在/home/webapp下面写个index.py:

import web
urls = (
    '/', 'index',
    '/test', 'index1'
    )

app = web.application(urls, globals(), autoreload=True)
class index:
    def GET(self):
        return 'hello world!'
class index1:
    def GET(self):
        return 'hello test!'

application = app.wsgifunc()

    
if __name__ == "__main__":
    app.run()


然后命令行:

service apache2 restart






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值