apt-get install apache2
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
版权声明:本文为mengjiexu_cn原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。