Installing a Python application – DjangoCMS example
The following article will guide you through installing a Python WSGI application by example of the popular DjangoCMS environment.
Please note that the article assumes basic understanding of Linux consoles (SSH). Should you have trouble installing the application or using the console, please do not hesitate to contact our support for additional support. Lines starting with “#” are console commands
NOTE: SSH Access is disabled by default on most webhosting account as a safety precaution. Please open a support ticket to have SSH enabled free of charge. As an additional anti-bot precaution SSH is not on the default port 22 but on port 2244.
1. Prepare the webserver
Connect to your cPanel account and click on ‘Setup Python app’. Adapt the following settings as needed. Directory names and paths can be changed depending on your preference but must remain consistant throughout the application.
Version: Python 3.4
App Domain: <yourdomain> / myapp
Create application. Take note of the “Command for entering virtualenv”, it’s needed in the next step.
2. Install your application
Connect to SSH by using host yourdomain with port 2244 and your regular cPanel login details.
Switch to the folder of your application:
# cd mypythonapp
!! Now copy-paste the “command for entering the virtualenv” from cPanel
Install django-cms dependencies
# pip install djangocms-installer
Deploy djangocms into the current directory
# djangocms -s -f –timezone Europe/Luxembourg -p . mysite
3. Connect the webserver to your application
In cPanel go to ‘Setup Python app’ and scroll to the application we created in step 1.
Click on “WSGI File location” and set it to (no quotes) “mysite/wsgi.py:application”
Click on “Update”, then on “Restart”. Your Python application is now accessible under the “App Domain” defined in Step 1.
4. Configure your DjangoCMS application
Before you can start with your DjangoCMS application you need to allow your domain for usage.
Open mypythonapp/mysite/settings.py in the file editor of your choice and edit “ALLOWED_HOSTS” to contain your domain name.
NOTE: Some Changes in Python applications, like this one, require you to restart the application server. In CPanel under ‘Setup Python app’ click on ‘Restart’ for your application to apply the settings.