Django CMS Installation to the Cloud

By | December 11, 2018

django cms installationDjango CMS is a free open-source content management system based on the Django web framework, which ensures a quick integration of the databases and new modules. Django CMS helps to simplify the process of creating complex websites due to its intuitive and easy-to-learn drag and drop interface. Simultaneously, it is powerful and expandable enough to satisfy the most demanding content editors.

Below, we’ll overview the steps required to automatically or manually install the Django CMS solution to the cloud.

Django CMS Automatic Installation

You can automatically get a preconfigured ready-to-work Django CMS instance up and running within minutes using Jelastic Marketplace.

Tip: If you don’t have an account, you can automatically get it and, simultaneously, initiate Django CMS solution installation by clicking the button below and fulfilling the form within the opened page.cms installation guide

1. Log in to your Jelastic account and click the Marketplace button at the top of the dashboard.cms manual installation

2. Search for the DjangoCMS solution in the opened window.cms automatic installation

Hover over the located package and click Install.

3. Within the appeared installation frame, you can adjust the following fields:

  • Environment – set your environment name
  • Display Name – define a preferable alias
  • Region – select the environment region (if multiple are available)

django cms tutorial

Proceed with the Install button.

4. That’s it! In just a few minutes your Django CMS application will be installed.python hosting

Use the info within the pop-up to access your Django CMS home and admin panel pages.

Django CMS Manual Installation

You can deploy Django CMS manually with the help of the following step-by-step instruction and take the complete control over the process.

Let’s start by creating an environment for the Python applications hosting. To do this, follow the next steps:

1. Click the New environment button.install django cms

2. Navigate to the Python programming language tab, where the Apache application server will be selected automatically. State the resource limits, choose the region (if available) and enter the name (e.g. django-cms) for your environment.python cms

Notes:

  • Currently, the Django CMS does not support Python 3.7, so select the version appropriately.
  • Django CMS requires a database for work; herewith, you can use:
  • SQLite is implemented by default and does not require any additional configurations (data is stored locally on the same container as your application); this solution is suitable for the development and testing purposes
  • external SQL database (e.g. MySQL or PostgreSQL) is a secure and reliable option to be used for the production environments

Finally, click Create at the bottom right corner of the frame.

3. Just in a minute, your environment will appear at the dashboard.content management system

Now, you can install Django CMS from scratch or deploy your existing application into the environment. We’ll check both these options one-by-one.

Install Django CMS

1. Connect to your application server via Web SSH:django installation guide

2. You should create an isolated virtual Python environment for your application, using the virtual environment tool, which allows managing projects’ dependencies independently and without the administrator privileges:

virtualenv virtenv

python

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

source virtenv/bin/activate

deploy django python

4. Install the Django CMS installer using the pip package manager:

pip install djangocms-installer

django hosting

Wait a minute for the operation to be completed.

5. Next, remove the pre-installed application and create a new Django CMS application:

rm -rf ROOT

djangocms -p . ROOT -s

Tip:  You can read more about Django CMS installer arguments at the official documentation. For example, use the -w option to enable wizard mode installation and manually define various specific settings.  

python cloud hosting

6. Edit the mod_wsgi module (the /var/www/webroot/ROOT/wsgi.py file) by replacing its content with the lines below:

import os,sys
virtenv = os.path.expanduser('~') + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    if sys.version.split(' ')[0].split('.')[0] == '3':
        exec(compile(open(virtualenv, "rb").read(), virtualenv, 'exec'), dict(__file__=virtualenv))
    else:
        execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
    pass

sys.path.append(os.path.expanduser('~'))
sys.path.append(os.path.expanduser('~') + '/ROOT/')

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

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

deploy django application

Save the made changes.

7. Also, adjust the next parameters in the /var/www/webroot/ROOT/settings.py configuration file:

ALLOWED_HOSTS = ["{envDomain}"]

MEDIA_ROOT = os.path.join(DATA_DIR, 'ROOT', 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'ROOT', 'static')

STATICFILES_DIRS = (
		os.path.join(BASE_DIR, 'ROOT', 'static_local'),
)

Note: The ALLOWED_HOSTS option contains a list of strings representing the domain names, which this Django site can serve (django-cms.jelastic.com in our case). Also, can be set as * to match any host.If using an external database, the connection details should be specified within the DATABASES section, where:

  • ENGINE – change the database type (django.db.backends.mysql for the MySQL database or django.db.backends.postgresql_psycopg2 for PostgreSQL)
  • NAME, USER, PASSWORD – provide the data on the dedicated DB and account to connect
  • HOST – get the value from the email received after DB creation
  • PORT – set the port (3306 for MySQL or 5432 for PostgreSQL)

python env

Don’t forget to Save the changes.

8. Create new subdirectories for the static/media content and run the synchronization of resources:

mkdir ROOT/static_local

mkdir ROOT/media

python manage.py collectstatic

django tutorial

9. That’s all! Now, you can access your environment by clicking Open in Browser.cms installation

Within the opened page log in to the admin panel using the default admin/admin credentials.cms

Here, you can immediately start working by creating your first page with Django CMS.

Deploy Existing Django Application

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

Note: If configuring own deployment archive, please ensure your Django package contains the following files in its root:

  • requirements.txt file with the names of all the Python modules your application requires, it will be read by the deployment script to install the listed modules via the pip manager automatically
  • wsgi.py file with the entry point script for running your application inside a virtual environment using the mod_wsgi for Apache

1. Upload your application to the deployment manager, for example:

https://download.jelastic.com/public.php?service=files&t=37fb2dedbc72453fe73fbe2e890a10f2&download

django application

2. Deploy your Django application into the environment with the Apache Python application server.cloud cms

3. In a minute (after successful deployment), click the Open in Browser button for your environment to access the application.open source cms

4. Great! Your Django application is up and running in just a few minutes!

With our example, you’ll be redirected to the Django CMS admin panel, where you should log in with the default jelastic/jelastic credentials to start working.django cms

As you can see, it’s quite easy to deploy Django-based applications with the Jelastic Python hosting. Try it yourself with free trial on one of the Jelastic service providers.

Related Аrticles

Mezzanine CMS: Python-Based Hosting with Jelastic PaaS

Deploy Wagtail Python-Based CMS into Jelastic PaaS

 

Subscribe to get the latest updates