使用 apache 部署 django 时遇到问题

发布于 2024-09-30 23:27:45 字数 690 浏览 4 评论 0原文

您好,我在 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.

有什么想法吗?

Hello I am having a problem with Django trying to get it deployed on a server using apache. for some reason when I write this information in my httpd.conf file.

<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>

I get this error when I restart 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.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

徒留西风 2024-10-07 23:27:45

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

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/

this error is pretty much self explanatory (second line is important to you):

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

PythonHandler is a command unknown by apache. it's a "module command" known by mod_python. so if missing it says invalid command (OR defined by module not in...).

so make sure mod_python is installed.

you might know it anyways, but just follow this document http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

冰魂雪魄 2024-10-07 23:27:45

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

对 mod_python 的支持将是
在未来版本中已弃用
姜戈。如果您正在配置新的
部署,你很强
鼓励考虑使用 mod_wsgi
或任何其他支持的
后端。

Also, i recommend you use mod_wsgi instead of mod_python. See deprecation warning on top of this page: http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/

Support for mod_python will be
deprecated in a future release of
Django. If you are configuring a new
deployment, you are strongly
encouraged to consider using mod_wsgi
or any of the other supported
backends.

絕版丫頭 2024-10-07 23:27:45

python_mod 未安装或未在 httpd.conf 中配置。
如果您已安装它,请在 httpd.conf 中添加以下行:

LoadModule python_module modules/mod_python.so

python_mod is not installed or not configured in httpd.conf.
If you have installed it, then add this line below in httpd.conf:

LoadModule python_module modules/mod_python.so
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文