[英]mod_wsgi Target WSGI script cannot be loaded as Python module
Follow flask's doc : 遵循烧瓶的文档 :
http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/ http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/
Apache/2.4.10 flask 0.12.2 Apache / 2.4.10烧瓶0.12.2
Directory Structure: 目录结构:
├── movie_douban.py
├── movie_douban.wsgi
└── app
├── web
├── models
├── templates
└── static
movie_douban.wsgi: movie_douban.wsgi:
activate_this='/root/.local/share/virtualenvs/movie_douban-og6kh8C1/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
import sys
sys.path.insert(0, '/root/.local/share/virtualenvs/movie_douban-og6kh8C1/lib/python3.4/site-packages/')
from movie_douban import app as application
Apache: 阿帕奇:
<VirtualHost *:80>
ServerName gdd.python.com
WSGIDaemonProcess movie_douban user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/movie_douban/movie_douban.wsgi
ErrorLog "/private/var/log/apache2/python-error_log"
<Directory /var/www/movie_douban>
WSGIProcessGroup movie_douban
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
Apache Error: Apache错误:
[Sun Apr 29 10:59:56.835279 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] mod_wsgi (pid=16942): Target WSGI script '/var/www/movie_douban/movie_douban.wsgi' cannot be loaded as Python module.
[Sun Apr 29 10:59:56.835321 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] mod_wsgi (pid=16942): Exception occurred processing WSGI script '/var/www/movie_douban/movie_douban.wsgi'.
[Sun Apr 29 10:59:56.835470 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] Traceback (most recent call last):
[Sun Apr 29 10:59:56.835603 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] File "/var/www/movie_douban/movie_douban.wsgi", line 2, in <module>
[Sun Apr 29 10:59:56.837206 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] with open(activate_this) as file_:
[Sun Apr 29 10:59:56.837265 2018] [wsgi:error] [pid 16942] [remote 172.17.0.1:50790] IOError: [Errno 13] Permission denied: '/root/.local/share/virtualenvs/movie_douban-og6kh8C1/bin/activate_this.py'
root@345ad0ab8386:/var/www/movie_douban# ls -l /root/.local/share/virtualenvs/movie_douban-og6kh8C1/bin/activate_this.py
-rwxrwxrwx 1 root root 1137 Apr 28 03:31 /root/.local/share/virtualenvs/movie_douban-og6kh8C1/bin/activate_this.py
What should I do? 我该怎么办?
Permission denied error is usually caused by incorrect owner, group, or file mode setting of the file to be loaded or one of the subdirectories leading to it. 权限被拒绝错误通常是由要加载的文件或导致该文件的子目录之一的所有者,组或文件模式设置不正确引起的。 Another possible cause is SELinux, but only if it is enabled and in enforcing mode. 另一个可能的原因是SELinux,但前提是已启用它并且处于强制模式。
Permission denied: '/root/.local/share/virtualenvs/movie_douban-og6kh8C1/bin/activate_this.py'
In this case, almost certainly the Apache process has no access to /root
directory (ie admin's home directory), because it is running under UID of apache or httpd user. 在这种情况下,几乎可以肯定,Apache进程无法访问/root
目录(即admin的主目录),因为它在apache或httpd用户的UID下运行。
You should move your virtualenv files to a more suitable location. 您应该将virtualenv文件移动到更合适的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.