Django的部署来的UserDir [英] deploying django to UserDir

查看:138
本文介绍了Django的部署来的UserDir的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我们的学生服务器上部署Django的我的宠物项目。我们有Apache2中的UserDirmod和我没有访问Apache2的配置文件。如何部署? :-D

I would like to deploy my django pet-project on our student server. We have apache2 with UserDir mod and I don't have access to apache2 config files. How do I deploy? :-D

我来从PHP的背景,我被上传到我的部署我的PHP脚本的public_html DIR,一切都显示了上的 http://ourserver.com/~myusername 。我读Django文档,它说我应该补充<地点>有些东西与LT; /地点> 我们的Apache的配置文件。我没有访问它,所以我试图把它在.htaccess我在的public_html DIR并没有奏效。我用Google搜索了很多,我觉得我读的地方你不能把<地点> 在.htaccess,但现在我找不到报价

I come from PHP background and I deploy my PHP scripts by uploading them to my public_html dir and everything shows up on http://ourserver.com/~myusername. I read django documentation and it says I should add <Location>some stuff</Location> to our apache config file. I don't have access to it, so I tried putting it in .htaccess in my public_html dir and that didn't work. I googled a lot and I think I read somewhere you can't put <Location> in .htaccess, but now I can't find that quote.

所以,有人在这里部署的Django到的UserDir没有骚扰Apache的管理员?

So, anybody here deployed django to UserDir without harassing apache admins?

编辑:
我测试了mod_python格雷厄姆邓普尔顿建议<一href=\"http://stackoverflow.com/questions/1491102/deploying-django-to-userdir/1496446#1496446\">here,我可以使用mod_python的没有问题。另外,我发现错误日志和这里是错误日志中说,当我把&LT;地点&gt;有些东西与LT; /地点&gt; 在.htaccess:

edit: I tested mod_python as Graham Dumpleton advised here, and I can use mod_python without problems. Also, I found error log and here is what error log says when I put <Location>some stuff</Location> in .htaccess:

[周四10月1日21时33分十九秒2009] [警惕] [客户188.129.74.66] /path/to/my/.htaccess:其中,位置这里不允许

所以,好像我真的不能把&LT;地点&gt; 成的.htaccess。所以,我有哪些选择?

So, it seems like I really can't put <Location> into .htaccess. So, what are my options?

推荐答案

如果安装mod_python的,先看看你是否能真正地使用它,而无需管理员做任何事情。阅读:

If mod_python installed, first see if you can actually use it without needing administrator to do anything. Read:

http://www.dscpl.com.au/wiki/ModPython/文章/ GettingModPythonWorking

除非你是一个值得信赖的用户或管理员不知道他们在做什么,他们不应该被允许你使用mod_python的,因为你的code会Apache用户如果运行其他人也运行的应用程序相同的方式你可以与每个人的应用程序和数据干扰。换句话说,它是不安全的,不应该在共享托管环境中使用多个用户在同一个Apache实例。

Unless you are a trusted user or administrators don't know what they are doing, they shouldn't be allowing you to use mod_python because your code will run as Apache user and if anyone else also running applications same way, you could interfere with each others applications and data. In other words it isn't secure and shouldn't be used in shared hosting environments where multiple users on same Apache instance.


更新1

在此基础上,你现在有工作的mod_python,你应该能够像更换mptest.py的内容:

On the basis that you now have mod_python working, you should be able to replace contents of mptest.py with something like:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import sys
sys.path.insert(0, '/some/path/to/project/area/mysite')
sys.path.insert(0, '/some/path/to/project/area')

from django.core.handlers.modpython import handler as _handler

def handler(req):
  req.get_options()['django.root'] = '/~myusername/mptest.py'
  return _handler(req)

显然,在各种路径和值应根据您的命名改变。

Obviously, various paths and values in that should be changed per your naming.

该网站将作为/~myusername/mptest.py访问。

The site would be accessed as '/~myusername/mptest.py'.

在这一点上,你会发现使用傻mod_python的是你没有的Apache控制。这是因为,当你在你的网站改变code,则需要询问管理员重新启动Apache了你被拾起更改。

At this point you will find out silly using mod_python is where you don't have control of Apache. This is because when you change code in your site, you will need to ask the administrators to restart Apache for you for your changes to be picked up.

在守护进程模式与您的守护进程的所有者使用的mod_wsgi就会好很多,但如果他们已经在运行mod_python的,我不会建议他们在加载同一时间两个模块,mod_python的问题搞砸了在使用中的mod_wsgi某些情况下,如果他们没有正确安装了Python,你只是可能有很多的问题,所以不值得的麻烦。

Using mod_wsgi in its daemon mode with you as owner of daemon process would be much better, but if they are already running mod_python I wouldn't be recommending they load both modules at same time as mod_python issues screw up use of mod_wsgi in some cases and if they haven't installed Python properly, you are just likely to have lots of issues and so not worth the trouble.

总之,在你没有Apache的控制是愚蠢的和不安全的共享托管环境中使用mod_python的。

In short, using mod_python in shared hosting environment where you have no control of Apache is silly and insecure.

尽管如此,已经证明如何运行的Django出每个用户的目录我不认为它已被记录在任何地方做previously。

All the same, have documented how to run Django out of per user directory as I don't think it has been documented anywhere previously.

这篇关于Django的部署来的UserDir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆