使用python3.6和python2和django 2手动启动uwsgi

时间:2019-05-29 18:27:23

标签: django uwsgi

我刚刚开始使用uWSGI和Django。我想手动调用它。 我正在使用python36,Django 2,并且如果我在venv中安装uWSGI(pip install uwsgi),一切正常。

Q1。在venv之外使用时,我首先安装了uWSGI:

pip install uwsgi-> 2.0.18版本

已安装的插件:sudo apt-get install python3-setuptools

尝试与python36一起运行:

uwsgi --plugin-dir=/usr/lib/uwsgi/plugins --plugin python3 --master --http :5000 --home ~/my_playground/webapps/ --chdir ~/my_playground/webapps/p_tscze/ --module p_tscze.wsgi:application

/usr/lib/uwsgi/plugins中的插件:

/usr/lib/uwsgi/plugins$ ls | grep python3
asyncio_python36_plugin.so
asyncio_python3_plugin.so
python36_plugin.so
python3_plugin.so

获得的结果->注意python 2.7:

!!! UNABLE to load uWSGI plugin: ./python36_plugin.so: undefined symbol: uwsgi_legion_scrolls !!!
*** Starting uWSGI 2.0.18 (64bit) on [Wed May 29 18:04:24 2019] ***
compiled with version: 7.4.0 on 29 May 2019 15:30:14
os: Linux-4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019
nodename: start-tehnicka
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /usr/lib/uwsgi/plugins
detected binary path: /usr/local/bin/uwsgi
chdir() to /home/anel/my_playground/webapps/p_tscze/
your processes number limit is 3618
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :5000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:34279 (port auto-assigned) fd 3
Python version: 2.7.15rc1 (default, Nov 12 2018, 14:31:15)  [GCC 7.3.0]
Set PythonHome to /home/anel/my_playground/webapps/
ImportError: No module named site

所以请您告诉我我做错了什么吗?

Q2。当比较管理页面(./manage.py runserver)的结果和使用uwsgi前端获得的结果不相同时,为什么?

预先感谢

1 个答案:

答案 0 :(得分:0)

供以后参考:

wget https://projects.unbit.it/downloads/uwsgi-2.0.18.tar.gz
tar -xzvf uwsgi-2.0.18.tar.gz
cd uwsgi-2.0.18
python3 uwsgiconfig.py --build nolang #build binary with python3
python3 uwsgiconfig.py --plugin plugins/python nolang python36 # create a new binary

运行新创建的二进制文件uwsgi(我们可以链接到该二进制文件):

./uwsgi  --plugin-dir=/home/anel/uwsgi-2.0.18 --plugin python36 --master --http :5000 --home ~/my_playground/webapps/  --chdir ~/my_playground/webapps/p_tscze/ --module p_tscze.wsgi:application