1

您好,我在 Django 尝试使用 apache 将其部署在服务器上时遇到问题。出于某种原因,当我将此信息写入我的 httpd.conf 文件时。

<location "/mysite">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
    PythonDebug off
    PythonPath "['/user/local/src/djcode','/user/local/src/djcode/mysite'] + sys.path"
</Location>

重新启动 apache 时出现此错误。

Syntax error on line 3 of /etc/apache2/httpd.conf:
Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.

有任何想法吗?

4

3 回答 3

2

这个错误几乎是不言自明的(第二行对你很重要):

Invalid command 'PythonHandler', perhaps misspelled 
or defined by a module not included in the server configuration

PythonHandler 是 apache 未知的命令。这是 mod_python 已知的“模块命令”。因此,如果缺少它,则表示命令无效(或由不在...中的模块定义)。

所以确保安装了 mod_python。

无论如何您可能都知道,但只需遵循此文档http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

于 2010-11-08T10:12:05.043 回答
1

另外,我建议您使用mod_wsgi而不是 mod_python。请参阅此页面顶部的弃用警告:http: //docs.djangoproject.com/en/1.2/howto/deployment/modpython/

对 mod_python 的支持将在 Django 的未来版本中被弃用。如果您正在配置新部署,强烈建议您考虑使用 mod_wsgi 或任何其他受支持的后端。

于 2010-11-08T10:16:51.250 回答
1

python_mod未安装或未配置httpd.conf。如果你已经安装了它,那么在下面添加这一行httpd.conf

LoadModule python_module modules/mod_python.so
于 2012-07-22T01:07:10.823 回答