-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpy.sh
executable file
·60 lines (45 loc) · 1.59 KB
/
webpy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Web.py
# http://webpy.org/
#
apt-get install python-setuptools python-flup
easy_install web.py
mkdir -p /srv/www/webpy_bench
echo '#!/usr/bin/env python
# -*- coding: utf-8 -*-
import web
urls = ("/.*", "hello")
app = web.application(urls, globals())
class hello:
def GET(self):
return "Hello, world!"
if __name__ == "__main__":
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
app.run()
' > /srv/www/webpy_bench/index.py
chmod +x /srv/www/webpy_bench/index.py
echo 'server {
listen 82;
server_name localhost;
root /srv/www/webpy_bench/;
location / {
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
}
} ' > /etc/nginx/sites-available/webpy_bench
ln -s /etc/nginx/sites-available/webpy_bench /etc/nginx/sites-enabled/webpy_bench
spawn-fcgi -d /srv/www/webpy_bench -f /srv/www/webpy_bench/index.py -a 127.0.0.1 -p 9002