Django 和 mod_python 配置

发布于 2024-08-30 20:04:34 字数 646 浏览 7 评论 0原文

我的 Django 项目位于 /www/host1/htdocs/my/project 中,wwwmy 是其他实际文件夹的链接。 Apache 已启用 mod_python。我在 project 文件夹中有一个 .htaccess

SetHandler python-program 
PythonHandler django.core.handlers.modpython 
SetEnv DJANGO_SETTINGS_MODULE project.settings 
PythonDebug On 
PythonOption django.root /my/project 
PythonPath "['/www/host1/htdocs/my/project'] + sys.path"

我想我的网站应该可以从 http://host1/my/project 访问,但我看到以下错误:

ImportError:无法导入设置'project.settings'(它在sys.path上吗?它有语法错误吗?):没有名为project.settings的模块

有人可以给出任何建议吗?

My Django project is placed in /www/host1/htdocs/my/project, www and my are links to other actual folders. Apache has mod_python enabled. I have a .htaccess in project folder:

SetHandler python-program 
PythonHandler django.core.handlers.modpython 
SetEnv DJANGO_SETTINGS_MODULE project.settings 
PythonDebug On 
PythonOption django.root /my/project 
PythonPath "['/www/host1/htdocs/my/project'] + sys.path"

I suppose my site should be accessible from http://host1/my/project, but I see the following error:

ImportError: Could not import settings 'project.settings' (Is it on sys.path? Does it have syntax errors?): No module named project.settings

Can somebody give any suggestions?

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

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

发布评论

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

评论(2

吃不饱 2024-09-06 20:04:35

我的 Conf 文件包含以下几行:

SetHandler python-program
PythonPath "['c:/projectparentdir']+sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project.settings
PythonOption django.root /project
PythonDebug On

我能看到的唯一区别是我的 python 路径指向项目父目录。

在使用 Django 和 mod_python 一段时间后,我非常热衷于尝试 mod_wsgi,这显然是一种更强大的方法。

My Conf file has the following lines:

SetHandler python-program
PythonPath "['c:/projectparentdir']+sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project.settings
PythonOption django.root /project
PythonDebug On

The only difference I can see is that my python path points to the projects parent directory.

After using Django for a while with mod_python I am very keen to try out mod_wsgi, apparently a much more robust method.

琉璃梦幻 2024-09-06 20:04:34

使用:

PythonPath "['/www/host1/htdocs/my', '/www/host1/htdocs/my/project'] + sys.path"

即..父文件夹和项目文件夹。

还要确保 Apache 用户有权读取目录中的内容并在适当的地方进行写入。

Use:

PythonPath "['/www/host1/htdocs/my', '/www/host1/htdocs/my/project'] + sys.path"

Ie.. parent and project folder.

Also ensure Apache user has rights to read stuff in your directories and write where appropriate.

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