A installation guide for getting Django setup on WebFaction
-
Sign Up for an account on WebFaction: Affiliate with 2 months free | Non-Affiliate
-
Login
-
Click
Domains/Websites
>Applications
>Add New Application
-
Create a Django project with the following:
Name: "cfehome" # or whatever you call your project below. App Category: Django App type: Django 1.X.Y (mod_wsgi 4.5.X/Python 3.5)
NOTE The
Django
application version we are going to use is1.10.2
; select your version and replace X & Y with the version you're working with.Hit
Save
-
Create a Static Only folder for STATIC_ROOT
-
Click
Domains/Websites
>Applications
>Add New Application
-
Create a
Static
Application with the following:Name: "cfehome_static_root" App Category: Static App type: Static only (no .htaccess)
Hit
Save
-
-
Create a Static Only folder for MEDIA_ROOT
-
Click
Domains/Websites
>Applications
>Add New Application
-
Create a
Static
Application with the following:Name: "cfehome_media_root" App Category: Static App type: Static only (no .htaccess)
Hit
Save
-
-
Create Website:
-
Click
Domains/Websites
>Websites
>Add New Website
-
Create a website with the following:
Name: cfehome_website Security: Normal website (http) Status: Enabled Domains: <yourusername>.webfactional.com
-
In Contents, click
Add Application
>Reuse An Existing Application
select your Django Projectcfehome
. Keep url blank -
In Contents, click
Add Application
>Reuse An Existing Application
select your Static Rootcfehome_static_root
. Addstatic
to the url -
In Contents, click
Add Application
>Reuse An Existing Application
select your Media Rootcfehome_media_root
. Addmedia
to the url
-
-
Navigate to https://my.webfaction.com/ & Login (if needed)
-
In the
Web Server
section, note theweb374.webfaction.com
portion. -
Open Terminal (or PuTTY on Windows)
-
Run
ssh <username>@<server-id>.webfaction.com
likessh cfedeploy@web374.webfaction.com
-
If first time doing
ssh
into your server, you should see:The authenticity of host 'web374.webfaction.com (2607:f0d0:1104:4:16::2)' can't be established. RSA key fingerprint is SHA256:Dc9MghuhqWF1LoCzf6S31KbVSkLphayrrD7KmYHREKw. Are you sure you want to continue connecting (yes/no)?
Say Yes
-
Navigate to your Django project: Login process returns something like:
$ ssh cfedeploy@web374.webfaction.com Last login: Wed May 26 02:42:36 2016 from 123.09.64.12 [cfedeploy@web374 ~]$ ls bin lib logs webapps
Now navigate to your django project
[cfedeploy@web374 ~]$ cd webapps [cfedeploy@web374 webapps]$ ls cfehome cfehome_media_root cfehome_static_root htdocs [cfedeploy@web374 webapps]$ cd cfehome [cfedeploy@web374 cfehome]$ ls apache2 bin lib myproject
Remove pre-installed Django project listed as
myproject
:rm -rf myproject
Create a Django Local Project following this guide
-
Open an FTP Client (like Transmit or Cyberduck)
-
SFTP into your Webfaction Account
-
Navigate to your webapp in
/webapps/cfehome
-
Download
apache2/conf/httpd.conf
, update the settings as:WSGIDaemonProcess cfehome processes=2 threads=12 python-path=/home/cfedeploy/webapps/cfehome:/home/cfedeploy/webapps/cfehome/src:/home/cfedeploy/webapps/cfehome/lib/python3.5 WSGIProcessGroup cfehome WSGIRestrictEmbedded On WSGILazyInitialization On WSGIScriptAlias / /home/cfedeploy/webapps/cfehome/src/cfehome/wsgi.py
-
Navigate back to
/webapps/cfehome
-
Drag Your Local project, we call
cfehome
through CyberDuck/Transmit to/webapps/cfehome
-
Update
production.py
with the following settings:ALLOWED_HOSTS = ['cfedeploy.webfaction.com'] STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), ) STATIC_ROOT = "/webapps/cfehome_static_root/" MEDIA_ROOT = "/webapps/cfehome_media_root/"
-
Setup Domain Name Nameservers to Webfaction and add domain to Webfaction:
Nameserver ns1.webfaction.com ns2.webfaction.com ns3.webfaction.com ns4.webfaction.com -
Add Domain to
ALLOWED_HOSTS
inproduction.py
:ALLOWED_HOSTS = ['cfedeploy.webfaction.com', 'www.spormicro.com']
-
Upload changed files (such as
httpd.conf
andproduction.py
) and ensurelocal.py
is not in the project. -
SSH via Terminal/PuTTY to Webfaction Project and Restart Apache:
cd webapps/cfehome ./Apache2/bin/restart
-
Set
Python Path
inside of your app withPYTHONPATH=$PYTHONPATH:$PWD/lib/python
-
Collectstatic:
python3.5 manage.py collectstatic
-
Any Django commands should now work using
python3.5
first:python3.5 manage.py migrate python3.5 manage.py createsuperuser
All set!