python - configuring nginx to work with python3.2 -
i'm having trouble configuring nginx work python3.2. i'm struggling find resembling decent tutorial on subject. did find decent tutorial on getting nginx play nice python2.7. thought process since uwsgi works plugins should relatively simple exercise follow python2.7 tutorial , swap out python plugin.
here tutorial followed basic hello world site working: https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-12.04-precise-pangolin
/etc/uwsgi/apps_available/my_site_url.xml looks like:
<uwsgi> <plugin>python</plugin> <socket>/run/uwsgi/app/my_site_urlmy_site_url.socket</socket> <pythonpath>/srv/www/my_site_url/application/</pythonpath> <app mountpoint="/"> <script>wsgi_configuration_module</script> </app> <master/> <processes>4</processes> <harakiri>60</harakiri> <reload-mercy>8</reload-mercy> <cpu-affinity>1</cpu-affinity> <stats>/tmp/stats.socket</stats> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi>
once working installed uwsgi-plugin-python3 via apt-get. ls -l /usr/lib/uwsgi/plugins/
outputs:
-rw-r--r-- 1 root root 142936 jul 17 2012 python27_plugin.so -rw-r--r-- 1 root root 147192 jul 17 2012 python32_plugin.so lrwxrwxrwx 1 root root 38 may 17 11:44 python3_plugin.so -> /etc/alternatives/uwsgi-plugin-python3 lrwxrwxrwx 1 root root 37 may 18 12:14 python_plugin.so -> /etc/alternatives/uwsgi-plugin-python
changing python
python3
or python32
in my_site_url.xml has same effect, ie:
- the hello world page takes ages load (it instantanious before) , comes blank
- my site's access log records access
- my site's error log records no new error
/var/log/uwsgi/app/my_site_url.log records following:
[pid: 4503|app: 0|req: 1/2] 192.168.1.5 () {42 vars in 630 bytes} [sun may 19 10:49:12 2013] / => generated 0 bytes in 0 msecs (http/1.1 200) 2 headers in 65 bytes (1 switches on core 0)
so question is:
how can correctly configure app work on python3.2
the listed tutorial has following application code:
def application(environ, start_response): status = '200 ok' output = 'hello world!' response_headers = [('content-type', 'text/plain'), ('content-length', str(len(output)))] start_response(status, response_headers) return [output]
this incompatable python3.2 because expects bytes object. replacing application function following fixes things:
def application(env, start_response): start_response('200 ok', [('content-type','text/html')]) return b"hello world"
Comments
Post a Comment