Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在生产上的python web项目中使用root拥有的virtualenv_Python_Django_Nginx_Virtualenv_Uwsgi - Fatal编程技术网

在生产上的python web项目中使用root拥有的virtualenv

在生产上的python web项目中使用root拥有的virtualenv,python,django,nginx,virtualenv,uwsgi,Python,Django,Nginx,Virtualenv,Uwsgi,因此,我有以下配置: 带有uWsgi的Nginx服务器 Django项目的虚拟化 我的virtualenv由一个普通系统用户拥有,整个配置工作正常! uwsgi进程配置为使用nginx uid&gid以及nginx.conf中的nginx进程所有者运行 但是,如果我尝试使用另一个满足相同要求但归root所有的virtualenv,我的uwsgi将无法定位virtualenv,从而引发导入错误 这正常吗?我的建议是否正确使用root拥有的virtualenv 编辑: uwsgi配置: [uw

因此,我有以下配置:

  • 带有uWsgi的Nginx服务器
  • Django项目的虚拟化
我的virtualenv由一个普通系统用户拥有,整个配置工作正常! uwsgi进程配置为使用nginx uid&gid以及nginx.conf中的nginx进程所有者运行

但是,如果我尝试使用另一个满足相同要求但归root所有的virtualenv,我的uwsgi将无法定位virtualenv,从而引发导入错误

这正常吗?我的建议是否正确使用root拥有的virtualenv

编辑:

  • uwsgi配置:

    [uwsgi]
    virtualenv = /root/Envs/rootenv
    thread = 4
    uid = nginx
    gid = nginx
    env = DJANGO_SETTINGS_MODULE=myServer.settings
    module = django.core.handlers.wsgi:WSGIHandler()
    chdir = /var/www/myServer
    socket = /var/run/uwsgi/myserver.sock
    logto = /var/log/uwsgi/myserver.log
    
  • /root/.bashrc:

    ### Virtualenv settings ###
    export WORKON_HOME=/root/Envs
    source /usr/local/bin/virtualenvwrapper.sh
    export PIP_VIRTUALENV_BASE=$WORKON_HOME
    export PIP_RESPECT_VIRTUALENV=true
    
  • uwsgi日志回溯:

    *** Starting uWSGI 1.9.15 (64bit) on [Fri Sep  6 14:02:41 2013] ***
    compiled with version: 4.7.2 on 06 September 2013 10:59:26
    os: Linux-3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2
    nodename: myserver3
    machine: x86_64
    clock source: unix
    pcre jit disabled
    detected number of CPU cores: 2
    current working directory: /
    detected binary path: /usr/local/bin/uwsgi
    setgid() to 32
    set additional group 4 (adm)
    setuid() to 32
    *** WARNING: you are running uWSGI without its master process manager ***
    your processes number limit is 7929
    your memory page size is 4096 bytes
    detected max file descriptor number: 1024
    lock engine: pthread robust mutexes
    uwsgi socket 0 bound to UNIX address /var/run/uwsgi/myserver.sock fd 3
    Python version: 2.7.3 (default, Jan  2 2013, 14:09:21)  [GCC 4.7.2]
    Set PythonHome to /root/Envs/rootenv
    ImportError: No module named site
    *** Starting uWSGI 1.9.15 (64bit) on [Fri Sep  6 14:03:13 2013] ***
    compiled with version: 4.7.2 on 06 September 2013 10:59:26
    os: Linux-3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2
    nodename: myserver3
    machine: x86_64
    clock source: unix
    pcre jit disabled
    detected number of CPU cores: 2
    current working directory: /
    detected binary path: /usr/local/bin/uwsgi
    setgid() to 32
    set additional group 4 (adm)
    setuid() to 32
    *** WARNING: you are running uWSGI without its master process manager ***
    your processes number limit is 7929
    your memory page size is 4096 bytes
    detected max file descriptor number: 1024
    lock engine: pthread robust mutexes
    uwsgi socket 0 bound to UNIX address /var/run/uwsgi/myserver.sock fd 3
    Python version: 2.7.3 (default, Jan  2 2013, 14:09:21)  [GCC 4.7.2]
    Set PythonHome to /root/Envs/rootenv
    ImportError: No module named site
    

能否添加导入错误、完整回溯和uwsgi配置?我已经编辑并添加了回溯