Saturday, July 4, 2015

Installing Django CMS on Ubuntu 14.04

NOVA Web Development is a web design and development coop I started with my friend Kevin Cole about three years ago.  I was motivated by a desire to make the IT program at my school relevant to my mostly working class, immigrant students.  As a career and technical education teacher, I'm suppose to be helping students find career paths, but despite the large number of IT jobs available, my students are caught in the catch-22 that they need experience (most want adds list three years) to get a job, but they need a job to get experience.  NOVA Web Development was created to find a way out of that bind.

Three years into the project, I would say we have been successful in getting off the ground, given we started with only funding I could provide and very limited experience.  We now have two former students (both of whom are in college) who are emerging as young web professionals, and who will soon be able to act as mentors to future students.

Our business focus is offering web design and web application development using mostly the Python web application framework Django. One of my goals for this Summer is to develop skills needed to help out with NOVA Web Development projects. To do that I'm going to need to learn how to setup and manage django CMS.

Since I want to be able to experiment without fear, the first thing I did was install VirtualBox on my Ubuntu 15.04 host machine using:

 $ sudo apt-get install virtualbox

Then I created a virtual machine (VM) through the GUI interface and installed Ubuntu 14.04 server on it.  I only selected SSH Server from the package installation menu during the install process to keep the machine minimal to start.  After the installation I logged into the VM and ran all the package updates, and then made a copy of the virtual hard drive (the file with extension .vdi in the VM's directory).  This will save me a lot of time in case I mess things up on the VM and want to start over (that's the "experiment without fear" part).

I always setup my virtualbox VMs with bridged network adapters:
Which gives the VM an addressable on the same network as the host machine.

With my VM server ready to go, I went looking on-line for some good reference material and found How to Install the Django Web Framework on Ubuntu 14.04. This guide discusses four alternative methods for installation. Of these I choose Install through pip in a Virtualenv (giving me a virtual environment on a virtual machine ;-).

Here's what I did:
  • $ sudo aptitude install python3-all-dev python3-pip
  • $ sudo aptitude install libtiff5-dev libjpeg8-dev
  • $ sudo aptitude install libfreetype6-dev liblcms2-dev
  • $ sudo aptitude install libwebp-dev tcl8.6-dev tk8.6-dev
  • $ sudo aptitude install python3-tk python-tk
  • $ sudo pip3 install virtualenv
  • $ mkdir cms1
  • $ cd cms1
  • $ virtualenv env
  • $ source env/bin/activate
  • (env)$ pip install django
  • (env)$ django-admin --version
  • (env)$ deactivate
With Django 1.8.2 installed, I left the virtualenv to return later after a break to install django-cms.
(note: This is an updated version of this post with modified installation steps.  When I ran the following process the first day, I encountered show stopping errors with lack of support in Pillow for jpeg and png -- described by others here. Today I copied over my virtual hard disk image to start with a fresh VM and began the process anew with the modified installation instructions above.  It worked. That's "experiment without fear" in action!)


To continue the installation process, here is what I did next:
  • $ cd cms1
  • $ source env/bin/activate
The Django installation guide continues with instructions on how to setup a project, but I want django-cms, so I switched to Installing django CMS for the next steps:
  • (env)$ pip install djangocms-installer
  • (env)$ mkdir testproj
  • (env)$ cd testproj
  • (env)$ djangocms -p . testsite
  • Now give the following to the installer's questions:
    • Database configuration (in URL format): sqlite://localhost/project.db
    • django CMS version: stable
    • Django version: stable
    • Activate Django I18N / L10N setting: yes
    • Install and configure reversion support: yes
    • Languages to enable. Option can be provided multiple times, or as a comma separated list: en, de
    • Optional default time zone: America/New_York
    • Activate Django timezone support: yes
    • Activate CMS permission management: yes
    • Use Twitter Bootstrap Theme: yes
    • Use custom template set: no
    • Load a starting page with examples after installation: yes
  • Create admin user when prompted
  • (env)$ python runserver

I then opened a web browser in the host machine and pointed it at the virtual machine. Here is a screenshot of part of my desktop showing this:
In the screenshot of my desktop above, my host machine had address and the VM has address  I used ssh from my host machine to login to the VM, since the terminal program on the host is nicer to use than the one you get logging in directly from virtualbox.

You have to add[port number] to the end of the runserver command to allow web connections to the VM from other machines.  I then point the browser on my host machine to[port number] (8000 in this case, but you can use any port number above 1024 you like) and am rewarded by the Welcome to django CMS home page!

Later I'll start learning how to use django CMS.

No comments:

Post a Comment