apache2 and mod wsgi : Target WSGI script cannot be loaded as Python module

只谈情不闲聊 提交于 2019-12-05 04:31:39

You would appear to be following the wrong documentation for starters. For mod_wsgi use:

You appear to be using documentation for FASTCGI deployment.

Also, you cannot do:

import test-wsgi

A Python module name cannot have '-' in it.

In summary, go reread (or read) the Django documentation on deployment.

For me the problem was wsgi python version mismatch. I was using python 3, so:

$ sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi
$ sudo apt-get install libapache2-mod-wsgi-py3

I had the same problem for a differnt file and making the file world executable fixed it for me. You would of course want to lock it down to the required user after you have narrowed this down as your issue:

chmod a+x test-wsgi.py
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!