How to Get Mezzanine CMS inside Jelastic Cloud

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

mezzanineMezzanine CMS (content management system) is a powerful and easy-to-use solution for content management and blogging, which is build on top of Django – Python-powered web-development framework. This BSD-licensed open-source platform is free and easy-customizable. The most required and widely-used CMS functionality is provided by default, so it can cover the majority of common needs. At the same time, there exist a huge number of third-party extensions, widgets, modules, themes etc, which can be used to broaden Mezzanine possibilities.

Both developers and content managers can be pleased with such pretty advantages of this platform as:

  • WYSIWYG editor with the Drag-and-Drop page ordering and visual content editing
  • scheduled publishing
  • huge amount of ready-to-use themes
  • rich API
  • out-of-the-box Django internationalization, Twitter Bootstrap, Disqus, Akismet spam filter, Twitter feed and Google Analytics support, as well as embedded integration with social networks, search engines, SEO functionality and, huge amount of modules

So, today we’ll consider how such a great application can be easily hosted at Jelastic PaaS&CaaS –  the step-by-step instruction below will pass you through the Mezzanine CMS deployment process inside Jelastic Cloud.

Create Python Environment

To start with, you need to create an environment with the appropriate application and DB server. In our case, the Apache Python server is needed (with the Python 2.7 engine version as recommended).

1. To create such, log in to your dashboard and press the New environment button. image15

2. Switch to the Python tab. Here, with the appropriate application server being already chosen, you need to state the suitable Python version. Then, define the needed environment region (in case of using the multi-region cloud) and adjust the domain name. image19


  • Jelastic provides both Python 2 (2.7) and Python 3 (3.3, 3.4, 3.5) versions; herewith, 2.7 is the most suitable one for Mezzanine CMS deployment (though Python 3 is supported by this app as well).
    To find out the details on possible compatibility issues, please read the official documentation at Mezzanine CMS community.
  • In case you are going to deploy a 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, located inside the application server container – both of these options will be described further down this guide.

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

3. Just in a minute your environment will appear at the dashboard.image16

Now, you are ready to proceed to the actual Mezzanine CMS application deployment.

Build and Deploy Mezzanine CMS

1. In order to install Mezzanine CMS from the scratch, you need to access your application server via the Jelastic SSH Gateway first.

Tip: If you haven’t performed such operations before, you need to:

However, in case you are not able to connect to your account via SSH (e.g. due to your hosting provider restrictions), you may proceed with deployment of the preliminary prepared Mezzanine 4.1 archive, provided at the very end of this article.

2. After entering the Apache Python server by means of terminal, you will find yourself in the jelastic user home directory. Now, to run the Python web application, the isolated virtual environment needs to be created.

Tip: A virtual environment is a tool for keeping the dependencies, that are required by different Python projects, in separate places. In addition, it gives the ability to install the required packages without having the administrator privileges.

So, in order to create such an environment, simply run the following command via your console:

virtualenv virtenv

3. To be used, the newly created virtual environment needs to be activated by executing the next command:

source virtenv/bin/activate

4. Now, the Mezzanine CMS installer can be downloaded with the help of the Python package manager (pip):

 pip install mezzanine

image11Wait for a couple of minutes before this operation is completed.

5. Since we are going to install our application to the ROOT context, the existing ROOT folder with the default application should be preliminary removed:

rm -rf ROOT

After that, you can run the installer:

mezzanine-project ROOT

The next required action is creation of the application database schema.

Configuring Database

Mezzanine CMS, as all Django-based applications, supports different SQL DBs. You can choose the one according to your purposes and preferences, so within the instruction below we’ll reveal how to configure our app to work with:

  • inbuilt SQLite database
  • a separate SQL server (either MySQL-based or PostgreSQL)

For the Embedded SQLite DB

Being fast, simple and lightweight, SQLite represents a great solution for development and testing purposes.

Tip: For production environments, it’s recommended to use either MySQL-based or PostgreSQL node, as they provide the sufficient level of scalability and security for real-life cases (the detailed instruction for these servers is provided right down the article)

1. The DB connection settings can be seen within the file inside the ~/ROOT/ROOT folder. Here, you’ll find the dedicated DATABASE configuration section with the parameters being stated for the SQLite DB engine usage by default, so you can leave them unchanged in this case.image20

2. After you’ve reviewed the settings, execute the following line from inside the ~/ROOT directory (i.e. one level above the script location) in order to create a new SQLite database:

python createdb --noinput
Tip: At this step, the default administration account (with admin/default as credentials), site record and some demo pages are created. If you’d like to specify the data for these options manually, simply run the command above without the ‘–noinput‘ option.

image17The DB itself will be stored in ~/ROOT/dev.db.

3. After the DB is created, you can proceed to the Configuring Apache section of this article a little bit below.

For a Separate SQL Server

At Jelastic, Mezzanine can be configured to work with any of the provided MySQL-based servers (i.e. MySQL itself, MariaDB or PerconaDB – the settings are completely the same for all of them). Also, you can use PostgreSQL as an option.

Here, we’ll consider the required configuration with the example of PerconaDB 5.6, whilst providing the corresponding settings for Postgres alongside if they differ.

1. So, if you prefer to use a separate DB server – navigate back to Jelastic dashboard, choose the Change environment topology option for your Mezzanine environment, pick up the desired node within the SQL wizard section and click on Apply.image24

  • Note: Percona DB is an optional node, since it is based on cartridge packaging model. In case you’d like to use it but can’t find this server in the SQL section of your wizard, send a request to your hosting provider for its enabling.

2. After the node is successfully added to your environment, select Open in browser next to it for the PhpMyAdmin page to be opened. Log in with the credentials you’ve received via email during server installation:image14

3. Once you’re inside, navigate to the Users tab in order to create a separate account for interaction with Mezzanine CMS database. In the opened frame, click on Add user and specify the appropriate username and password.image08

Also, tick the Create database with the same name and grant all privileges and Grant all privileges on wildcard name (username\_%) options to get a DB with the required privileges. Then press the Go button

Tip: As for the PostgreSQL database, the only necessary action is creation of a new database upon the default DB user.
For that, after being logged in, select the Create database link. Within the appeared input form, specify the name for your new DB, leaving all the rest of settings unchanged, and click on the Create button.image06

4. After the successful DB creation, return to your console with the opened SSH connection to the Apache Python server and navigate to the file inside the ~/ROOT/ROOT folder. Here, you need to specify the following configurations:

  • ENGINE – django.db.backends.mysql (or django.db.backends.postgresql_psycopg2 for PostgreSQL database)
  • NAME – type the name of the previously created database (mezzanine in our case)
  • USER and PASSWORD – enter the ones you’ve specified during the DB creation (or state the default credentials if using PostgreSQL)
  • HOST – internal IP of the chosen DB server
  • Tip: In order to find out the server’s IP address, expand the Additional list next to it at the Jelastic dashboard:image12
  • PORT – specify the 3306 port number (or 5432nd one if working with PostgreSQL)

As a result, the DATABASES section should look similar to the following:image25

5. Then, in order to make the server to work with MySQL-based DB, the appropriate connector needs to be installed via pip:

pip install mysql

Tip: To get Python connector for PostgreSQL server, the next command should be run:

PATH=$PATH:/usr/pgsql-9.4/bin/ pip install psycopg2

Please also note that you may need to modify the pgsql-9.4 string according to the provided version of PostgreSQL server at your Jelastic Platform.

6. Once the required SQL module is installed, you can proceed with DB schema creation:

python createdb --noinput

After the DB is created, let’s ensure the application is operable and apply some additional application server configurations.

Running Mezzanine Application

So, the main steps of Mezzanine CMS application installation are completed now. In order to quickly make sure that everything was accomplished successfully, just stop the default Apache Python process:

sudo service cartridge stop

and then start the app itself (from inside the ~/ROOT folder):

python runserver

Now, you can Open your environment in browser via Jelastic dashboard to access the application start page:image00

Such kind of application running is suitable for development and testing purposes. However, for production environments with a big number of concurrent users, it’s more preferable to launch Apache web server (which will be used for the static content serving) in a bundle with mod_wsgi module (required for hosting of Python web applications with the WSGI specification support and for implementing interaction with Python backend).

So, to handle the Mezzanine application with mod_wsgi, do the following:

1. First of all, you need to generate a WSGI handler. For that, enter the ~/ROOT/ROOT directory via console (upon SSH protocol) and create the file there with such content:

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

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

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

from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name

application = get_wsgi_application()

image02Save the newly created file.

2. Then, set the symlink, which will point to the file we’ve modified above, by executing the following line:

ln -sfT ~/ROOT/ROOT/ ~/ROOT/application

  3. Also, as we are going to serve static content with the help of Apache, the appropriate data needs to be collected beforehand (the command should be run under the ~/ROOT directory):

python collectstatic

image04As a result, all of the static content for current app will be stored in the ~/ROOT/static directory.

4.  In addition, there are a couple of small issues, which are needed to be adjusted within the ~/ROOT/ROOT/ config before we can start the app, namely:

  • state the ROOT_URLCONF parameter to ROOT.ROOT.urlsimage22
  • substitute the ALLOWED_HOSTS setting value with your Jelastic environment domain name (which can be seen within the dashboard)

5. After that, run the Apache process by:

sudo service cartridge start

6. That’s all! Now, you can return to the dashboard and press Open in browser button next to your environment with Mezzanine CMS (similarly to the way you’ve done this while checking its operability). As a result, you’ll see the application’s welcome page.image05

Here, you can login to admin panel using your credentials (i.e. admin/default in case of the –noinput option usage, or your custom ones otherwise)

Once inside, you are able to proceed with modifying your site and filling it with the required content.image10

Deploying Pre-Configured Mezzanine CMS Archive

For the case you have a trial-type account and/or do not have the possibility to access your environment via SSH, the archive with pre-configured Mezzanine CMS application can be deployed directly via the Jelastic dashboard. As an example, you can use our ready-to-go Mezzanine 4.1 package.

Note: In case of deploying your custom Mezzanine distribution, please ensure it contains the following files in its root:

  • requirements.txt file with the names of all the Python modules the application requires. This file will be read by deployment script in order to automatically install the listed modules with the help of the pip manager.
  • application file with the entry point script for running your application inside a virtual environment by means of Apache mod_wsgi.

With our package, SQLite is used for serving data storing by default, so only app server is needed to be comprised within an environment. And the whole deployment procedure can be performed just in a few steps, described below:

1. Upload the package with your Mezzanine CMS application to the Jelastic dashboard via Deployment manager.image09

2. Press the Deploy to button and choose the target environment.image23

3. Once this operation is finished, select the Open in browser button next to your environment.image18

4. That’s all! Now you can enjoy working with your Mezzanine CMS application.image21

As you can see, it’s quite easy to deploy Mezzanine CMS (as well as any other Django-based application) with Jelastic Python hosting. Nevertheless, in case you face any issues with this instruction, feel free to appeal for our technical experts’ assistance at Stackoverflow.

And don’t forget to keep an eye on new articles within our blog  – here you can find the variety of instructions and solutions you can benefit on with your own account at any of Jelastic Cloud installations. So stay tuned!

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates