4

I have been learning Django in the development mode for a two months and I am up to speed with most basic aspects of python + django now. However, I was using the built-in runserver till this time

Now, I have got a Webfaction hosting account and wanted to know the following

1) Webfaction sets up the project with a certain Django version (say 1.6.4) and Python version (say 2.7) initially

The project directory (for say project MYAPP) is /<>/webapps/MYAPP

When the site is running in production mode, how does the apache server know which Python version, and which site-packages versions to use with the MYAPP source code to render the site?

I can see that the MYAPP folder has a lib/python2.7 folder, however when I am connected to SSH terminal, and do a "which python", i see :

which python
/usr/local/bin/python

so, do I take that this is the Python executable that is being used for rendering the website instead of the one in webapps/MYSITE/lib/python2.7 folder? How does the information/data flow about which programs to use during rendering the site with apache mod_wsgi work?

2) I was using a virtualenv in the development mode during testing. How do I use this on webfaction in production mode?

3) I am using Pycharm IDE. It worked well for the development mode. I can see that it has a remote interpreter configuration and a Deployment setting/option.

The python path that the remote interpreter settings tool detects automatically is the python executable at /usr/local/bin/python

Is this fine, or should I be pointing it to the more local python2.7 in the webapps/lib folder?

Thanks a lot of the answers and pls let me know if you need any supplemental info

dowjones123
  • 3,695
  • 5
  • 40
  • 83

1 Answers1

1

Note to the OP: This should really be three separate questions.

1) For WebFaction, your Django app will use the Python version (and libraries, etc.) defined in:

~/webapps/<appname>/apache2/conf/httpd.conf

Specifically, you'll want to look at what is defined for WSGIPythonPath (which should mostly match up with WSGIDaemonProcess unless you modify the config and are doing something strange).

Note that which python just tells you what the default python is in your shell. This has nothing to do with the config file for the webapp.

2) You may want to expand on this as to exactly what your use case is and why the default Django webapp created by WebFaction doesn't fit your needs. But the short answer is:

  • Create a virtualenv on your WebFaction account.
  • Install Django, etc. into the virtualenv.
  • Edit the httpd.conf file I mentioned above to use your virtualenv instead.

I've done this with both a Django webapp made via the WebFaction control panel and via a custom mod_wsgi webapp. So it does work. Just make sure to use the right Python version when making your virtualenv.

3) I don't use PyCharm so I can't answer this (one reason why this question should be split up).

Michael Cheng
  • 9,644
  • 6
  • 46
  • 48