WebFaction
Community site: login faq

There are threads scattered here and there about using virtual environments and Django.

They all seem to be four or five years old (or older).

My first assumption was that a user could upload the virtual environment (containing the Django installation) to the server, update the settings.py file to point to the database, and get started.

The instruction threads all seem to have various instructions created by different commenters. It's hard to tell what to do and what actually works.

Is there an up-to-date, step-by-step guide specifically for installing an existing Django development site onto WebFaction's servers using a Python virtual environment (venv)?

asked 10 May, 05:33

altsocial
112
accept rate: 0%

edited 10 May, 05:35


Use https://my.webfaction.com/new-application to create a new django application.

I've used django 2.0.5 (mod_wsgi 4.6.4/Python 3.6) which was the most recent at the time of this writing, and named it django.

This created a new directory named ~/webapps/django and using SSH I connected to the server and with the cd command I went into that.

There, I've run rm -rf bin/ lib/ to remove the pre-installed django libraries.

Next step is python3.6 -m venv . in order to create the virtual environment, with source bin/activate to activate it.

If pip is not pre-installed, in ~/webapps/django/bin, you will need to run curl https://bootstrap.pypa.io/get-pip.py | python to get the latest version.

You would then need to upload your code in the ~/webapps/django directory. Each developer has its own way of structuring their source code, but I'll go with the one similar to the pre-installed myproject directory.

If you have a requirements.txt file run pip install -r requirements.txt to install all your dependencies, orpip install django` to only install the django library.

As per our Using a virtual environment with mod_wsgi guide, to configure apache, you will need to edit ~/webapps/django/apache2/conf/httpd.conf and change the following line from...

WSGIDaemonProcess django processes=2 threads=12 python-path=/home/your_username/webapps/django:/home/your_username/webapps/django/myproject:/home/your_username/webapps/django/lib/python3.6

... to ...

WSGIDaemonProcess django processes=2 threads=12 python-home=/home/your_username/webapps/django python-path=/home/your_username/webapps/django/myproject

... where your_username is your account's username.

Restart your server with ./apache2/bin/restart and that should be it.

permanent link

answered 10 May, 07:49

iliasr ♦♦
2.0k14
accept rate: 36%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×901
×337
×54
×1

question asked: 10 May, 05:33

question was seen: 760 times

last updated: 10 May, 07:49

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM