I am trying to configure django with apache. I do see two different site-packages directory in my system:
/usr/lib64/python2.6/site-packages
/usr/local/lib64/python2.6/site-packages
The django and all the necessary libraries are installed in
/usr/local/lib64/python2.6/site-packages
How do I ensure apache reads the path as default python library?
You don't have to worry about that. Python will look for packages in both of those paths.
From Python docs :
First, consider that many Linux distributions put Python in
/usr
, rather than the more traditional/usr/local
. This is entirely appropriate, since in those cases Python is part of "the system" rather than a local add-on. However, if you are installing Python modules from source, you probably want them to go in/usr/local/lib/python2.X
rather than/usr/lib/python2.X
.
You just need to configure the path to your django project's wsgi.py
file. You can do it like this:
WSGIScriptAlias / /path/to/mysite/mysite/wsgi.py
WSGIPythonPath /path/to/mysite
<Directory /path/to/mysite/mysite>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
Note that wherever I've written mysite/mysite
it means your project's inner directory (which contains settings, wsgi, etc. files)
EDIT
In case you want to see if those folders are in Python's search path , you can do this:
>>> import sys
>>> sys.path
# outputs python search path
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.