apache mod_wsgi错误与django在virtualenv中(apache mod_wsgi error with django in virtualenv)
我似乎无法找到一个好的答案。 在将其作为WSGIDaemon运行时,谁需要拥有virtualenv? 我假设我的操作系统(Ubuntu 16)www-data,但我想确定。 根据这篇文章的答案,尝试一些新的东西让这件事工作......
django apache配置与WSGIDaemonProcess无法正常工作
django项目,virtualenv文件夹或两者都需要由apache组拥有吗? 在没有指定端口的情况下,需要为django项目提供什么样的所有权? 为什么我会得到以下内容?
根本问题:
Call to 'site.addsitedir()' failed for '(null)'
当我启动Apache时,我收到此错误。 我遵循了几个不同的指南,包括: http : //modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html和https://docs.djangoproject.com/en/1.10/howto/部署/ wsgi / modwsgi /但没有成功。
我的虚拟环境路径是
/usr/local/virtualenvs/servicesite
我的django项目路径是
/home/addohm/projects/rtservice/servicesite
这是manage.py所在的位置 ,它将/home/addohm/projects/rtservice/servicesite/servicesite
留作我的wsgi.py的位置。wsgi.py:
SERVICESITE = ['/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages'] import os import sys import site prev_sys_path = list(sys.path) for directory in SERVICESITE site.addsitedir(directory) new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path """ **Doesn't seem to work, throwing error in apache logs** site.addsitedir('/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages') """ from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "servicesite.settings") application = get_wsgi_application() DJANGO_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') sys.path.append(DJANGO_PATH)
apache2.conf
[...]
WSGIDaemonProcess servicesite python-path=/home/addohm/projects/rtservice/servicesite:/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages WSGIProcessGroup servicesite WSGIScriptAlias / /home/addohm/projects/rtservice/servicesite/servicesite/wsgi.py Alias /static/ /home/addohm/projects/rtservice/servicesite/static/ <Directory /home/addohm/projects/rtservice/servicesite/static/> Require all granted </Directory> <Directory /home/addohm/projects/rtservice/servicesite/servicesite> <Files wsgy.py> Require all granted </Files> </Directory>
[...]
I can't seem to find a good answer to this. Who needs to own the virtualenv when running it as a WSGIDaemon? I assume on my OS (Ubuntu 16) www-data, but I want to be sure. Trying some new things to get this thing working based off of the answer from this post...
django apache configuration with WSGIDaemonProcess not working
Does the django project, the virtualenv folder, or both need to be owned by the apache group? What ownerships need to be in place to serve a django project without specifying a port? Why do I get the following?
The root problem:
Call to 'site.addsitedir()' failed for '(null)'
When I start apache, I get this error. I've followed several different guides, including: http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html and https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/ but have had zero success.
My virtual environment path is
/usr/local/virtualenvs/servicesite
My django project path is
/home/addohm/projects/rtservice/servicesite
this is where manage.py resides, which leaves/home/addohm/projects/rtservice/servicesite/servicesite
as the location of my wsgi.py.wsgi.py:
SERVICESITE = ['/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages'] import os import sys import site prev_sys_path = list(sys.path) for directory in SERVICESITE site.addsitedir(directory) new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path """ **Doesn't seem to work, throwing error in apache logs** site.addsitedir('/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages') """ from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "servicesite.settings") application = get_wsgi_application() DJANGO_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') sys.path.append(DJANGO_PATH)
apache2.conf
[...]
WSGIDaemonProcess servicesite python-path=/home/addohm/projects/rtservice/servicesite:/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages WSGIProcessGroup servicesite WSGIScriptAlias / /home/addohm/projects/rtservice/servicesite/servicesite/wsgi.py Alias /static/ /home/addohm/projects/rtservice/servicesite/static/ <Directory /home/addohm/projects/rtservice/servicesite/static/> Require all granted </Directory> <Directory /home/addohm/projects/rtservice/servicesite/servicesite> <Files wsgy.py> Require all granted </Files> </Directory>
[...]
原文:https://stackoverflow.com/questions/39948367
最满意答案
自己想出来: 什么是Hi / Lo算法?
Figured it out myself: What's the Hi/Lo algorithm?
相关问答
更多-
关于postgresql中使用SEQUENCE的一个问题[2021-03-09]
insert语句后加个returning就行了 insert into .... returning ID; returning后的格式类似于select的, 返回值格式也类似于select ID from ... -
sql中sequence的用法[2021-09-09]
insert into PRODUCT (你建的序列.NEXTVAL,PRD_DESCRIPTION) values (id,description) 在每次插入数据的时候,id都会按你建的序列的增量自动增加。 sequence就是所谓的序列号,每次取的时候它会自动增加,一般用在需要按序列号排序的地方。 1、 create sequence 你首先要有create sequence或者create any sequence权限, create sequence emp_sequence INCREMENT ... -
将“class”消息发送到类的实例的含义是什么(What is the meaning of sending the “class” message to an instance of a class)[2022-04-07]
它用于调用FBSDKLoginButton的initialize方法。 +(void)initialize是在初始化类的任何实例之前调用的方法。 它只召唤一次。 [FBSDKLoginButton class]用于触发要调用的initialize方法。 It is used to call the initialize method of the FBSDKLoginButton. The +(void)initialize is a method that is called before any ins ... -
当ListIterator对象中的迭代按指数正确的顺序返回时,与i1,i2是独立的: import java.util.ArrayList; import java.util.List; import java.util.ListIterator; public class Main { public static void main(String[] args) { List
list = new ArrayList (); ... -
序列与身份(Sequence vs identity)[2022-12-03]
我想你会在这里找到你的答案 使用列的标识属性,您可以轻松生成自动递增数字(通常用作主键)。 使用Sequence,它将是一个不同的对象,您可以在插入时附加到表列。 与身份不同,列值的下一个数字将从内存而不是从磁盘检索,这使得Sequence显着快于Identity。 我们将在下面的例子中看到这一点。 在这里 : 序列:SQL Server社区多年来已经请求了序列,并且包含在此版本中。 Sequence是用户定义的对象,用于生成一个数字序列。 以下是使用Sequence的示例。 在这里也是: SQL Serv ... -
什么是LSTM中的序列长度?(What is Sequence length in LSTM?)[2023-10-01]
LSTM是循环神经网络的一个子类。 递归神经网络被定义应用于连续数据,其不失一般性意味着随时间变化的数据样本。 然后通过有限时间窗口上的样本值来描述数据样本的完整历史记录,也就是说,如果您的数据存在于N维空间并随着时间步长演化,则您的输入表示必须是形状的(num_samples,t ,N)。 您的数据不符合上述说明。 然而,我认为这个表示意味着你有一个标量值x,它在7个时间点上演化,这样x [0] = 1.23,x [1] = 2.24等。 如果是这样的话,你需要重新塑形你的输入,而不是一个7个元素的列表, ... -
SecurityBits="11"表示Users can read and edit all items. Sequence="110"表示110 is the ordering priority to use for the list template on the Create page 阅读文档了解更多信息 SecurityBits="11" means Users can read and edit all items. Sequence="110" means 110 is the orderin ...
-
自己想出来: 什么是Hi / Lo算法? Figured it out myself: What's the Hi/Lo algorithm?
-
在C中,“字符串”被定义为以空字符结尾的char的数组(可能是较大数组的子数组)。 多字节字符串函数对字符串进行操作,处理多字节字符,直到它们到达字符串的末尾(或目标缓冲区中的空间不足)。 对字节“序列”( char s)进行操作的多字节字符函数一次只转换一个多字节字符(或者,在mbrtowc的情况下,可能甚至更少)。 不要求输入char数组是字符串。 In C, a "string" is defined as an array (possibly a subarray of a larger array ...
-
递归序列(Recursion Sequence)[2022-06-10]
您可以通过传递数组和start参数来完成此操作: private static boolean arrPattern(int[] arr) { return arrPattern(int[] arr, 0); } private static boolean arrPattern(int[] arr, int startpos) { ... } 在递归调用中传递startpos + 1 ,然后检查startpos是否在最后。 You can do this by passing an a ...