Apache 2.4(32 位)目标 WSGI 脚本无法加载为 Python 模块。 web.py
Apache 2.4(32bit) Target WSGI script annot be loaded as Python module. web.py
os:寡妇 2012r2
网络服务器:apache 2.4.23(32 位)
python: 2.7.12
网络框架:web.py 0.38
mod_wsgi: mod_wsgi-4.4.23+ap24vc9-cp27-cp27m-win32
我给apache服务器系统权限,所以可以排除权限原因。
这整个过程is:Http->Apache 2.4->mod_wsgi->web.py
wsgi.conf:
WSGIScriptAlias / "C:/Apache24/htdocs/test.py/"
Alias /static "C:/Apache24/htdocs/static/"
AddType text/html .py
<Directory "C:/Apache24/htdocs/">
Require all denied
Require all granted
</Directory>
============================================= ====
test.py:
coding:utf-8
import web
urls = (
'/.*', 'hello',
)
class hello:
def GET(self):
return "Hello, world."
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()
============================================= ====
然后,成功了!我打开IE,输入url:localhost:80,页面显示:Hello, world.
基于以上,我把wsgi.conf的代码改成:
============================================= ====
WSGIScriptAlias / "C:/Apache24/htdocs/code.py/"
Alias /static "C:/Apache24/htdocs/static/"
AddType text/html .py
<Directory "C:/Apache24/htdocs/">
Require all denied
Require all granted
</Directory>
============================================= ====
和 code.py:
coding: utf-8
import web
from config.url import urls
app = web.application(urls, globals())
application = app.wsgifunc()
============================================= ====
然后 apache 仍然有效,
但是 error.log 显示:"Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module."
而URL:localhost:80无法工作,显示:“500 Internal Server Error”
任何人都可以告诉如何解决这个问题?非常感谢。
error.log:
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi (pid=3780): Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module.
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi (pid=3780): Exception occurred processing WSGI script 'C:/Apache24/htdocs/code.py'.
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] Traceback (most recent call last):
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] File "C:/Apache24/htdocs/code.py", line 5, in <module>
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] from config.url import urls
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] ImportError: No module named config.url
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi (pid=3780): Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module., referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi (pid=3780): Exception occurred processing WSGI script 'C:/Apache24/htdocs/code.py'., referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] Traceback (most recent call last):, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] File "C:/Apache24/htdocs/code.py", line 5, in <module>, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] from config.url import urls, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] ImportError: No module named config.url, referer: 192.168.1.146
包含您的 config
package/module 的目录不在 Python 模块搜索路径中。您需要使用 WSGIPythonPath
指令通过 mod_wsgi 告诉 Python 解释器 运行 它在哪里。
os:寡妇 2012r2
网络服务器:apache 2.4.23(32 位)
python: 2.7.12
网络框架:web.py 0.38
mod_wsgi: mod_wsgi-4.4.23+ap24vc9-cp27-cp27m-win32
我给apache服务器系统权限,所以可以排除权限原因。
这整个过程is:Http->Apache 2.4->mod_wsgi->web.py
wsgi.conf:
WSGIScriptAlias / "C:/Apache24/htdocs/test.py/"
Alias /static "C:/Apache24/htdocs/static/"
AddType text/html .py
<Directory "C:/Apache24/htdocs/">
Require all denied
Require all granted
</Directory>
============================================= ====
test.py:
coding:utf-8
import web
urls = (
'/.*', 'hello',
)
class hello:
def GET(self):
return "Hello, world."
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()
============================================= ====
然后,成功了!我打开IE,输入url:localhost:80,页面显示:Hello, world.
基于以上,我把wsgi.conf的代码改成:
============================================= ====
WSGIScriptAlias / "C:/Apache24/htdocs/code.py/"
Alias /static "C:/Apache24/htdocs/static/"
AddType text/html .py
<Directory "C:/Apache24/htdocs/">
Require all denied
Require all granted
</Directory>
============================================= ====
和 code.py:
coding: utf-8
import web
from config.url import urls
app = web.application(urls, globals())
application = app.wsgifunc()
============================================= ====
然后 apache 仍然有效,
但是 error.log 显示:"Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module."
而URL:localhost:80无法工作,显示:“500 Internal Server Error”
任何人都可以告诉如何解决这个问题?非常感谢。
error.log:
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi (pid=3780): Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module.
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi (pid=3780): Exception occurred processing WSGI script 'C:/Apache24/htdocs/code.py'.
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] Traceback (most recent call last):
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] File "C:/Apache24/htdocs/code.py", line 5, in <module>
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] from config.url import urls
[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] ImportError: No module named config.url
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi (pid=3780): Target WSGI script 'C:/Apache24/htdocs/code.py' cannot be loaded as Python module., referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi (pid=3780): Exception occurred processing WSGI script 'C:/Apache24/htdocs/code.py'., referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] Traceback (most recent call last):, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] File "C:/Apache24/htdocs/code.py", line 5, in <module>, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] from config.url import urls, referer: 192.168.1.146
[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] ImportError: No module named config.url, referer: 192.168.1.146
包含您的 config
package/module 的目录不在 Python 模块搜索路径中。您需要使用 WSGIPythonPath
指令通过 mod_wsgi 告诉 Python 解释器 运行 它在哪里。