mod_wsgi对我来说很新鲜。 我按照这个文档的所有步骤(https://developers.yubico.com/u2fval/Apache_Deployment.html),但我得到一个错误。
我的步骤:
<IfModule mod_wsgi.c>
WSGIDaemonProcess u2fval python-home=/etc/yubico/u2fval/venv
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /wsapi/u2fval /etc/yubico/u2fval/u2fval.wsgi process-group=u2fval
<Directory /etc/yubico/u2fval>
Options None
AllowOverride None
AuthType Digest
AuthName "u2fval"
AuthUserFile /etc/yubico/u2fval/clients.htdigest
Require valid-user
</Directory>
</IfModule>
如果我尝试打开 http://localhost/wsapi/u2fval/ ,我会收到此错误:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求。
在 /var/log/apache2/error.log 中:
[Wed Mar 28 09:34:22.915421 2018] [mpm_prefork:notice] [pid 31834] AH00163: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Wed Mar 28 09:34:22.915487 2018] [core:notice] [pid 31834] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 28 09:34:39.052131 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] mod_wsgi (pid=31916): Target WSGI script '/etc/yubico/u2fval/u2fval.wsgi' cannot be loaded as Python module.
[Wed Mar 28 09:34:39.052197 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] mod_wsgi (pid=31916): Exception occurred processing WSGI script '/etc/yubico/u2fval/u2fval.wsgi'.
[Wed Mar 28 09:34:39.052514 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] Traceback (most recent call last):
[Wed Mar 28 09:34:39.052563 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] File "/etc/yubico/u2fval/u2fval.wsgi", line 1, in <module>
[Wed Mar 28 09:34:39.052658 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] from u2fval import app as application
[Wed Mar 28 09:34:39.052687 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] ImportError: No module named u2fval
任何人都可以帮助我吗?我几乎搜索了三个小时,但没有找到解决办法。
答案 0 :(得分:0)
如果您的应用程序代码位于/etc/yubico/u2fval
,请添加:
python-path=/etc/yubico/u2fval
到WSGIDaemonProcess
指令。
您需要告诉它应用程序代码的位置,因为它不会自动查找WSGI脚本文件所在的目录。
顺便说一下,错误消息中的路径与您的配置所说的WSGI脚本文件的位置不匹配。无论如何,根据需要调整该路径。