How do I modify sys.path from .htaccess to allow m

2019-04-10 11:43发布

问题:

The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it elsewhere (namely my user space) by modifying sys.path, but I don't know how to change it from .htaccess or mod_python.

How do I modify sys.path from .htaccess to allow mod_python to see Django?

P.S. I can only access the site via FTP (i.e. no shell access). I realize that it sounds like I should just switch hosts, but there are compelling reasons for me to make this work so I'm at least going to try.

回答1:

According to ticket #2255 for Django, you need admin access to httpd.conf in order to use Django with mod_python, and this is not going to change, so you may be dead in the water. To answer the basic question of how to modify sys.path from .htaccess, you can use the PythonPath directive in .htaccess.



回答2:

Is the PythonPath setting what you are looking for? I haven't tried it with Django, but I would assume that it should do the job for you.



回答3:

You're using mod_python wrong. It was never intended to serve python web applications. You should be using WSGI for this... or at least FastCGI.