本文主要是介绍Nginx+uWSGI+Django安装过程中遇到的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、安装uwsgi
最好通过python pip安装uwsgi:
sudo apt-get install python-pip
sudo apt-get install python-dev #不安装这个,下面的安装可能会失败
sudo pip install uwsgi
建议:sudo apt-get install uwsgi uwsgi-core uwsgi-plugin-python#uwsgi-plugin-python一定要安装
测试:
1.test.py
def application(env, start_response):
start_response(‘200 OK’, [(‘Content-Type’,’text/html’)])
return “Hello World”
执行shell命令:
uwsgi –http-socket :8001 –plugin python –wsgi-file test.py
(uwsgi –http :8001 –wsgi-file test.py会出错)
访问网页:
http://127.0.0.1:8001/
看在网页上是否有“Hello World”
参考
stackoverflow:
Ask:
uwsgi –http :8000 –home /home/cuser/.virtualenvs/vq –chdir /var/www/sid/sid -w wsgi.py
uwsgi: option ‘–http’ is ambiguous
getopt_long() error
Answer:
This is most likely because you have uwsgi installed from your distributions packaged binaries, which are more minimal in their build and lack some of the plugins.
You can fix this by either pip install uwsgi and replace uwsgi with path/to/uwsgi/binary/installed/using/pip. You can find that using pip show uwsgi.
[Please note: use pip3 if you’re using python3]
Another method would be to download the respective http/python3 plugins and running the following command:
uwsgi –plugins http,python –http :8000 –home /home/cuser/.virtualenvs/vq –chdir /var/www/sid/sid -w wsgi.py
这篇关于Nginx+uWSGI+Django安装过程中遇到的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!