Python Hosting in the Jelastic Cloud: Get Your DjangoCMS Up and Running

By | August 12, 2014


From the very beginning, Jelastic was architectured as a polyglot platform. We started with Java, then added PHP and Ruby but we didn’t stop at that. Month by month, our developers keep working on implementing new programming languages. Recently, Python has been added to our language family. Today we’d like to pay more attention to Python hosting in the Jelastic Cloud and provide a live sample of DjangoCMS (Python application) deployment.

NOTE: Python availability in the Jelastic Cloud can be configured by hosting providers via JCA (admin panel). In order to enable Python support for your users follow the instructions.


Jelastic Python Specifications

Currently we support Apache application server for hosting Python applications. It is implemented by means of Apache + mod_wsgi bundle.

In Jelastic, there are three Python versions currently available:

  • 2.7
  • 3.3
  • 3.4

All of these versions are pre-installed in each Python container. A user can choose the required version during environment creation or change it afterwards via the environment topology wizard. The workflow is described in the Python Versions document.

python versions


Application Deploy

You can easily deploy an already packaged Python application:

Note: that you can deploy just one Python app to the environment, so it will be in the ROOT context by default.

Also you can use the SSH feature for building and deploying a new custom application.


In order to deploy your own package, its root should contain the following files:

  • requirements.txt file with the names of all Python modules your application requires
  • application file with the entry point script for running your application using Apache mod_wsgi considering your virtual environment


Packages/Modules Management

In order to successfully deploy and run a Python application, some additional modules or other packages may be required to be installed. The management of the required software packages is provided by pip, popular Python package management system.

There are two ways to download and install necessary Python modules:

  • write a list of required modules in the requirements.txt file, located in the root of your project package. It will be read by a deployment script in order to automatically install these modules with the help of pip.
  • connect to your container via SSH and operate with the following commands:

pip install {package_name} – to install a necessary module
pip uninstall {package_name} – to remove previously installed module
pip install –upgrade{package_name} – to update the specified module to the latest version
pip install -r requirements.txt – to install all the modules, listed in the requirements.txt file
pip list – to see the set of already installed modules

Using additional commands and their attributes you can also specify the preferred module version, configure resolving of relative dependencies, show details on installed modules or search for the necessary ones in the PiPI packages repository. To find out more details on the commands you can use, navigate to the pip user guide.


Logs Monitoring

Jelastic makes the following log files available for Python WSGI:

  • access_log-{date}
  • error_log-{date}

These files can be seen by clicking on the Log button next to the Apache application server in the environment. Here, you can monitor all the actions performed within your Python environment.


Available Frameworks

Currently Jelastic supports the following Python frameworks:

  • Django
  • Flask

You can deploy different Python applications based on these frameworks. Read our documentation in order to set your own Quokka CMS application (Flask-powered app) in the Jelastic Cloud. And below, we will describe how to deploy and run DjangoCMS.


DjangoCMS Deployment

Django is an open-source framework for Python applications. It helps to simplify the process of creating complex and database-driven web-applications, each of which can consist of a few pluggable modules. Let’s see how to benefit from Django with Jelastic Cloud and its Apache + mod_wsgi bundle on the example of Django CMS application hosting.


Create an Environment

First of all, let’s create an environment for Python applications hosting. To do this, follow these steps:

1. Click Create Environment button.create environment

2. Navigate to the Python programming language tab. Apache application server will be chosen automatically. State the resource limits, enter the name of your environment (e.g. django), and click Create.

create env

  • You can also choose from the Python versions we provide by default: 2.7, 3.3 or 3.4. While choosing, you should take into the consideration the compatibility of the Django version you are going to use with the preferred Python version.
  • In the case you are going to deploy any large and highly visited application, it makes sense to add a separate DB node to your environment. Otherwise, you can use the default SQLite database, which will be located inside the application server container.

3. In just a minute your environment will appear at the dashboard.

django environment

For now, we can proceed to Django CMS application deployment in one of the following ways:


Build and Deploy Django CMS

1. Generate and add a public SSH key to your dashboard.

2. Establish the SSH connection to your Apache application server using the instruction about SSH Access.

3. After entering the container, ensure you are in the user’s home directory:

$  cd ~

4. Then, you should create a virtual environment for your application inside the container. In such a way, you’ll get an isolated Python environment and the ability to install packages without having the administrator privileges:

$  virtualenv virtenv

5. Activate and switch to the newly created virtual environment by executing the next command:

$ source virtenv/bin/activate

6. Now let’s install a set of required Django modules using PIP:

$ pip install django django-cms   djangocms_video  djangocms_teaser djangocms_picture djangocms_link  django-reversion djangocms_inherit  djangocms_googlemap djangocms_flash djangocms_file  djangocms_column djangocms-installer  djangocms_text_ckeditor djangocms_style

Wait a few minutes until this operation is completed.

7. Then, you should erase the default pre-installed application and create a new Django CMS app:

$ rm -rf ROOT; djangocms -p . ROOT

8. After executing the above mentioned command, you will see a set of questions, which will help you to define the settings of your new application.

Let’s pay special attention to the database configuration step:

  • In case you’ve added a separate DB node to your environment, specify the connection string to it, e.g mysql://mysql-{env_name}.{hoster_domain}
  • If you prefer to work with an in-built SQLite database, enter the next string:

Complete the remaining wizard steps by entering your custom values or leaving the default ones (displayed at the end of strings in the square brackets).wizard9. When the application is configured, you’ll be asked to specify Username, Email and Password for your CMS administrator (superuser).admin credentials

10. Next, enter the following command in order to create a new file and specify the entry point for mod_wsgi module in it:

$ vim ROOT/application

11. In the opened newly created file, enter the following lines:

import os,sys
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/')
        execfile(virtualenv, dict(__file__=virtualenv))
except IOError:


os.environ['DJANGO_SETTINGS_MODULE'] = 'ROOT.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Save the changes and exit VIM editor.

12. Now let’s link the static data:

  • enter $ vim ROOT/ command. In the opened file, replace the following string

        os.path.join(BASE_DIR, ‘ROOT’, ‘static’),


        os.path.join(BASE_DIR, ‘ROOT’, ‘static_local’),

Save the changes and exit VIM editor.    staticfiles dir

  • create a new subdirectory for static content:
    $ mkdir ROOT/static_local
  • and, finally, run the synchronization of resources:
    $ ./ collectstatic

Enter yes if system asks for confirmation.

That’s all! Now you can click the Open in browser button next to your environment in the dashboard to open your Django in browserYou will see the application’s welcome page.

welcome page

In order to access the Django CMS administration panel, add /admin at the end of the environment’s URL. For access, use the superuser credentials you specified while creating the Django CMS application.

django admin


Deploy an Existing Django Application

In the case you have previously built and packaged a Django application, the deployment procedure can be performed just in a few steps as described below.


In order to deploy your Django package, ensure it contains the following files in its root:

  • requirements.txt file with the names of all the Python modules your application requires. This file will be read by a deployment script in order to automatically install the listed modules with the help of PIP.
  • application file with the entry point script for running your application using Apache mod_wsgi considering your virtual environment. Examples for Django apps can be seen here.

1. Upload the package with your Django application to the Jelastic dashboard via the Deployment manager.

upload django package

2. Select the Deploy to button and choose a necessary environment.

deploy django

3. Wait a minute for deployment to be completed and then click the Open in browser button next to your environment.

open in browser

That’s all! Enjoy working with your Django application.package welcome



We are very excited to provide you Python hosting in Jelastic, with the features and flexibility to host and scale complex Python applications. We’ve made it easier than ever to develop and run Python apps, without vendor lock-in, in the data center of your choice, worldwide. In the nearest future we are going to enhance our documentation in order to provide more details on Python settings in the Jelastic Cloud. So stay tuned! Start now and try the beneficial features of Python hosting in the Jelastic Cloud.

Subscribe to get the latest updates