Apache2 + VirtualEnv IO错误:[Errno 13]权限被拒绝(Apache2 + VirtualEnv IOError: [Errno 13] Permission denied)
我无法通过virtualenv(和virtualenvwrapper)让apache服务我的网站。 我试着在这里进行演练。 值得注意的是,我使用的是Ubuntu Server v13.10,我读过它并没有本地支持Apache v2.2,因此在演练中我无法安装apache2.2-common。 但是,我不认为这是问题,因为Apache错误日志说有权限问题。
在我的设置中,虚拟环境存在于非root用户的主目录中,而apache服务器以root身份运行(我认为这很正常)。 我试图使用
namei
来追踪权限,并且确保以root
身份将chmod +rw
到路径中。 有任何想法吗?[Thu Mar 06 14:16:37.639031 2014] [mpm_event:notice] [pid 8771:tid 140338386122624] AH00489: Apache/2.4.6 (Ubuntu) mod_wsgi/3.4 Python/2.7.5+ configured -- resuming normal operations [Thu Mar 06 14:16:37.639144 2014] [core:notice] [pid 8771:tid 140338386122624] AH00094: Command line: '/usr/sbin/apache2' [Thu Mar 06 14:16:53.456622 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] mod_wsgi (pid=8775): Target WSGI script '/var/www/www.mysite.org/index.wsgi' cannot be loaded as Python module. [Thu Mar 06 14:16:53.456735 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] mod_wsgi (pid=8775): Exception occurred processing WSGI script '/var/www/www.mysite.org/index.wsgi'. [Thu Mar 06 14:16:53.456782 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] Traceback (most recent call last): [Thu Mar 06 14:16:53.456830 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] File "/var/www/www.mysite.org/index.wsgi", line 16, in <module> [Thu Mar 06 14:16:53.456918 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] execfile(activate_env, dict(__file__=activate_env)) [Thu Mar 06 14:16:53.456971 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] IOError: [Errno 13] Permission denied: '/home/nrUser/Envs/mysite/bin/activate_this.py' (mysite)root:~# namei -m /home/nrUser/Envs/mysite/bin/activate_this.py f: /home/nrUser/Envs/mysite/bin/activate_this.py drwxr-xr-x / drwxr-xr-x home drw-r--r-- nrUser drwxrwxr-x Envs drwxrwxr-x mysite drwxrwxr-x bin -rwxrwxr-x activate_this.py
I am having trouble getting apache to serve my site via virtualenv (and virtualenvwrapper). I tried following the walkthrough here. Of note, I am using Ubuntu Server v13.10 which I've read doesn't have native support for Apache v2.2 yet, thus in the walkthrough I was not able to install apache2.2-common. However, I don't think that is the issue as the apache error logs are saying there is a permissions problem.
In my setup the virtual environment lives in a non-root user's home directory, while the apache server runs as root (I think this is normal). I have tried to trace the permissions using
namei
and I've made sure tochmod +rw
to the path asroot
. Any ideas?[Thu Mar 06 14:16:37.639031 2014] [mpm_event:notice] [pid 8771:tid 140338386122624] AH00489: Apache/2.4.6 (Ubuntu) mod_wsgi/3.4 Python/2.7.5+ configured -- resuming normal operations [Thu Mar 06 14:16:37.639144 2014] [core:notice] [pid 8771:tid 140338386122624] AH00094: Command line: '/usr/sbin/apache2' [Thu Mar 06 14:16:53.456622 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] mod_wsgi (pid=8775): Target WSGI script '/var/www/www.mysite.org/index.wsgi' cannot be loaded as Python module. [Thu Mar 06 14:16:53.456735 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] mod_wsgi (pid=8775): Exception occurred processing WSGI script '/var/www/www.mysite.org/index.wsgi'. [Thu Mar 06 14:16:53.456782 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] Traceback (most recent call last): [Thu Mar 06 14:16:53.456830 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] File "/var/www/www.mysite.org/index.wsgi", line 16, in <module> [Thu Mar 06 14:16:53.456918 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] execfile(activate_env, dict(__file__=activate_env)) [Thu Mar 06 14:16:53.456971 2014] [:error] [pid 8775:tid 140338291197696] [client 192.168.XXX.XXX:50742] IOError: [Errno 13] Permission denied: '/home/nrUser/Envs/mysite/bin/activate_this.py' (mysite)root:~# namei -m /home/nrUser/Envs/mysite/bin/activate_this.py f: /home/nrUser/Envs/mysite/bin/activate_this.py drwxr-xr-x / drwxr-xr-x home drw-r--r-- nrUser drwxrwxr-x Envs drwxrwxr-x mysite drwxrwxr-x bin -rwxrwxr-x activate_this.py
原文:https://stackoverflow.com/questions/22234238
最满意答案
从编程上讲,您可以使用
GetType().IsValueType
。在Visual Studio中,您还可以使用对象浏览器进行检查(如下所示,位于“查看” - >“对象浏览器”下)。
Programmatically speaking, you can use
GetType().IsValueType
.From Visual Studio, you can also check by using the Object Browser (shown below, found under View -> Object Browser).
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
遗憾的是,在编译时无法检查类型是否都是算法。 这是我想念Java的(少数)功能之一。 但是,有一些很好的解决方法,根据您的情况,可能比您希望的解决方案更好。 例如: public abstract class Algorithm { } public class AlgorithmA : Algorithm { } public class AlgorithmB : Algorithm { } public interface IAlgorithmFactory { string Name {g ...
-
在C ++中, class和struct之间只有一个真正的区别。 在一个class ,默认可见性是private ,在一个struct ,默认可见性是public 。 通常,C ++程序员使用这些来表达不同的东西。 大多数情况下,如果你看到一个C ++程序员把某些东西写成一个struct ,它将是一个愚蠢的对象,意味着它可以直接访问字段。 例如: struct Point { int x = 0; int y = 0; }; Point p; p.x = 1; p.y = 10; 当同一个程序员写 ...
-
从编程上讲,您可以使用GetType().IsValueType 。 在Visual Studio中,您还可以使用对象浏览器进行检查(如下所示,位于“查看” - >“对象浏览器”下)。 Programmatically speaking, you can use GetType().IsValueType. From Visual Studio, you can also check by using the Object Browser (shown below, found under View -> ...
-
oxilumin是正确的,你现在的解决方案已经按你的要求工作。 但要回答你如何获得基础泛型类型的问题: var type = p_variable.GetType().BaseType.GetGenericArguments()[0]; oxilumin is right, your current solution already works as you want. But to answer your question on how to get the underlying generic typ ...
-
从上面的评论看来,你似乎已经知道自己想做什么了。 但这是一个快速的例子 class Program { static void Main(string[] args) { var properties = typeof(MyObject).GetProperties(); var stringsInMyObject = properties.Where(x=> x.GetMethod.ReturnType == typeof(string)); } } ...
-
为什么C#将整数类型实现为结构而不是基本类型?(Why C# implements integer type as a struct and not as a primitive type?)[2023-09-06]
这里的结构中没有“包装”。 出于所有实际目的, System.Int32 struct 是内置的基本类型,在编译器识别它们的意义上,并在处理基元类型的表达式时生成特殊指令。 包装int (或任何其他struct )的唯一位置是在装箱转换期间,当您想要将int传递给接受对象的API时,这是必需的。 Java和C#处理原语的最大区别在于,您可以在用户定义的struct类型可以使用的地方使用C#原语,最值得注意的是,在C#泛型参数中,而Java将原语视为完全独立的类型组。 There is no "wrappin ... -
Objective-C是否具有像C#这样的值/引用类型的概念?(Does Objective-C have concepts of value/reference type like C#?)[2022-11-04]
所有Objective-C对象都由指针访问。 从这个意义上说,它们都是参考类型。 某些Objective-C类型将对象相等性(-isEqual:方法)定义为指针相等之外的其他内容。 这些类型表现为类似值的类型。 这些类型包括NSString和NSNumber。 非Objective-C类的类型可以是C#意义上的真值类型。 All Objective-C objects are accessed by a pointer. In that sense they are all reference types. ... -
C#与结构内的列表混淆(值类型与引用类型)(C# Confused with a list inside a struct (value type vs reference type))[2022-03-18]
是的,它会在结构中创建一个值的副本 - 并且在结构内部有一个对List的引用,以便引用也被复制 - 这是一个“浅拷贝”...如果List已被复制到一个新的对象这将是一个“深层复制”...结构赋值使用“复制”语义,这取决于每个成员的复制语义...请参阅http://msdn.microsoft.com/en-us/library/saxz13w4.aspx yes it makes a copy of the values inside the struct - and inside the struct t ...