How to Deploy Quokka CMS to Jelastic Python Cloud

Quokka CMS is a Flask-powered, flexible Python CMS with a number of different themes available to suit anyone’s taste. It is easy to use and can be extended with a wast variety of useful modules. Also, this content management system provides a number of additional features you can benefit on, such as: customizable administrator interface, channel-based organization of content, role-based access control, etc.

In this instruction, we will find out how you can deploy and run your own Quokka CMS instance with the help of MongoDB and Flask - micro-framework, which is commonly used for developing simple applications on the base of number of available templates.

So, follow the detailed guidance below to accomplish this:

Create an Environment

To start with, let’s prepare a separate environment for our project by following the next instructions:

1. Press the New Environment button at the top pane of the dashboard.

2. In the opened topology wizard, navigate to the Python programming language tab. Here, the Apache application server will be chosen automatically as the only available one, so just add the MongoDB node within the NoSQL database section.

Specify cloudlet limits for the chosen nodes, select the region, enter the desired environment name (e.g. quokka), and click Create.

3. Your environment will appear at the dashboard in a minute.

Configure MongoDB

Now it’s time to create a new dedicated database, where all of the Quokka CMS data will be stored.

1. Press the Open in browser button next to the MongoDB node.

2. Within the opened page, log in to the MongoDB administration panel with credentials you’ve received via email after the environment creation.

3. Once authorized, move to the Databases section by clicking the appropriate button at the top pane. Locate the Create Database section inside and specify the name for a new database within it (e.g quokka).

Press Save when ready.

4. In a moment your new database will appear at the list, so you can move on and switch to the Execute panel tab. Here, you need to create an admin user for the DB by executing the corresponding piece of code:

db.createUser({user:"{name}", pwd:"{password}", roles:[{role:"readWrite", db:"{db_name}"}]})
where
  • {name} - name of a new database user
  • {password} - password for your user
  • {db_name} - name of the database you’ve created in the previous step

Note: The admin username refers to the default MongoDB user, so, obviously, you can’t use it as a name for your user.

Select your database within the drop down list and click the Execute button below to finish the DB configuration.

Build and Deploy Quokka CMS

After all the preparations are done, you can proceed directly to the Quokka CMS building and deploying to the Jelastic platform.

1. Access your Apache application server via the Jelastic SSH Gateway.

Tip: In case you haven’t performed similar operations before, you need to:

2. In order to get the ability to install the required packages without having the administrator privileges, you need to create an isolated virtual Python environment inside the container and, subsequently, perform all the actions there. So, execute the following commands for that:

virtualenv virtenv
source virtenv/bin/activate

3. Now, you should remove the default pre-installed application and deploy Quokka CMS app using the GIT repository as a source:

rm -rf ROOT; git clone https://github.com/pythonhub/quokka.git ROOT

4. Navigate to the ROOT folder with application files you’ve just downloaded and install the required Python modules (they are already listed within the requirements.txt file):

cd ROOT
pip install -r requirements/requirements.txt

5. Next, let’s specify the database connection data. Execute the vim quokka/settings.py command to open the appropriate configuration file, where you need to find the following strings and replace the default values with your own ones:

MONGODB_DB = “{db_name}”
MONGODB_HOST = '{db_ip}'
MONGODB_PORT = 27017
MONGODB_USERNAME = "{name}"
MONGODB_PASSWORD = "{password}"
where:
  • {db_name} - name of your database
  • {db_ip} - IP address of your MongoDB node

Tip: Your database node’s IP can be found in one of the following ways:

  • via SSH - while accessing your environment, you’ll see the full list of containers it consists of with the appropriate addresses within the LAN IP column

  • via the dashboard - expand the Additionally list by clicking on the gear icon next to the required node and copy address from the appropriate line

  • {name} - name of the admin user you’ve created earlier
  • {password} - password for this admin user

In order to save the changes and exit from the vim editor, use the :wq command.

6. Then, enter the vim wsgi.py command and specify the application entry point for mod_wsgi module by replacing the default content of the opened file with the following lines:

#!/usr/bin/python

import os,sys
virtenv = os.path.expanduser('~') + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    exec(open(virtualenv).read(), dict(__file__=virtualenv))
except IOError:
    pass

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

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

from quokka import create_app, create_api

application = DispatcherMiddleware(create_app(), {
    '/api': create_api()
})

if __name__ == "__main__":
    run_simple(
    '0.0.0.0',
    5000,

    application,
    use_reloader=True,
    use_debugger=True
    )

Save the changes you’ve made and exit the editor.

7. At last, let’s add a symlink for binding server’s entry point to the just modified file:

ln -s ~/ROOT/wsgi.py ~/ROOT/application

8. That’s all! Now you can return to the dashboard and press the Open in browser button next to your environment to launch your Quokka CMS.

Tip: Take into consideration that applications, which were deployed via SSH, are not displayed at the Jelastic dashboards’ Deployed column.

As a result, you will see the application’s welcome page with the automatically generated admin credentials stated, so you can instantly log in and start exploring.

Enjoy working with your own Quokka CMS application, hosted at Jelastic Cloud!

If you experience any difficulties while configuring or deploying Quokka CMS, you can appeal for our technical experts’ assistance at Stackoverflow.