nginx+uwsgi+flask
uwsgi 1.4.1
nginx 1.2.5
#content of config.xml
<uwsgi>
<pythonpath>/Users/bunny/workspace/gotrip/onepage</pythonpath>
<pythonpath>/Library/Python/2.7/site-packages/</pythonpath>
<module>test</module>
<callable>app</callable>
<socket>/tmp/uwsgi.sock</socket>
<master/>
<processes>4</processes>
<memory-report/>
</uwsgi>
#content of test.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def onepage():
return "hello, nginx"
if __name__ == '__main__':
app.run()
#script to start uwsgi
# !/bin/bash
pidof uwsgi | xargs sudo kill -9 #you may need this to restart uwsgi
sudo uwsgi -x config.xml &
#script to start nginx
# !/bin/bash
sudo chmod 777 /tmp/uwsgi.sock
pidof nginx | xargs sudo kill -9
sudo nginx &
More!
under /opt/local/etc/nginx
#nginx.conf, put the following at the right place, you will know it from nginx.conf.example
error_log logs/error.log; # logs/error should exists under /opt/local/etc/nginx
server {
listen 80;
server_name www.gotrip.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
include uwsgi_params; # this file should exists under /opt/local/etc/nginx
uwsgi_pass unix:/tmp/uwsgi.sock; # this file is created while execute uwsgi
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html; # html is under /opt/local, it's the place to put 50x.html, 404.html, etc....
}
}
#mime.types should exists under /opt/local/etc/nginx
you can also use nginx -p path to substitute /opt/local, but you should make sure all necessory files and dirs are at the right place

浙公网安备 33010602011771号