我无法通过virtualenv(和virtualenvwrapper)获取apache来为我的网站服务。我尝试按照演练here进行操作。值得注意的是,我使用的是Ubuntu Server v13.10,我读过它还没有对Apache v2.2的本机支持,因此在演练中我无法安装apache2.2-common。但是,我不认为这是问题,因为apache错误日志表示存在权限问题。
在我的设置中,虚拟环境位于非root用户的主目录中,而apache服务器以root身份运行(我认为这是正常的)。我尝试使用namei
跟踪权限,并确保chmod +rw
路径为root
。有任何想法吗?
[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
答案 0 :(得分:6)
为了能够访问这些文件,apache所有者至少需要文件上方所有目录的x位,以及文件本身的r位。您的nrUser目录缺少x位; chmod 755 /home/nrUser
应该解决您的问题。
答案 1 :(得分:0)
如果我没记错的话,Apache用户/组需要读取目录的权限。尝试将chown
应用于mysite
目录,例如:
sudo chown -R <user>:www-data mysite
&lt; - 在nrUser主目录中
使用sudo service apache2 restart
重启apache,看看是否可以访问您的网站。