Install Quokka on Centos

install-quokka-on-a-centos-vpsIn this blog post we will show you how to install Quokka on a Centos VPS with Nginx and uWSGI. Quokka is open source flexible content management system based on the Flask web framework . You can use Quokka to build a web portal, publish a blog or use it as a document management system . With the existing Quokka modules you can create an e-commerce application or fundraising website. This guide should work on other Linux VPS systems as well but was tested and written for a Centos 7 VPS.

Login to your VPS via SSH

ssh root@vps

Install the EPEL repository

To install the EPEL repository on your CentOS VPS, just run:

[root]$ rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

Update the system and install necessary packages

[root]$ yum -y update
[root]$ yum -y install git python-pip python-virtualenv pcre-devel python-imaging python-devel libjpeg-turbo-devel make gcc

Create a new system user

Create a new user for Quokka:

[root]$ adduser --comment 'Quokka User' --home-dir /home/quokka quokka
[root]$ chmod 755 /home/quokka

Install MongoDB

We will install the latest MongoDB 2.6 packages from the official MongoDB repository.

Create a /etc/yum.repos.d/mongodb-org-2.6.repo file and insert the following lines:

[root]$ nano /etc/yum.repos.d/mongodb-org-2.6.repo
[mongodb-org-2.6]
name=MongoDB 2.6 Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

Once you have saved the file, install MongoDB with the following command:

[root]$ yum -y install mongodb-org

Finaly start and enable MongoDB at boot:

[root]$ chkconfig mongod on
[root]$ systemctl start mongod

Create a python virtual environment and clone the Quokka source code

The following commands are run as quokka user. To switch to quokka user run:

[root]$ su - quokka

Create a new virtualenv using the following command

[quokka]$ virtualenv quokka-env

Clone the Quokka source code to the /home/quokka/quokka-env/quokka directory.

[quokka]$ cd quokka-env
[quokka]$ git clone https://github.com/quokkaproject/quokka

Switch to the new virtualenv

[quokka]$ source ~/quokka-env/bin/activate

Install all dependencies with:

(quokka-env)[quokka]$ cd quokka
(quokka-env)[quokka]$ pip install -r requirements/requirements.txt

If you want to populate the installation with sample data run :

(quokka-env)[quokka]$ /home/quokka/quokka-env/bin/python manage.py populate

Install and configure Nginx and uWSGI

Nginx is not available by default in CentOS 7 so we will use the official Nginx repository:

[root]$ rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

To install Nginx run:

[root]$ yum -y install nginx

Next, create a new Nginx server block:

[root]$ nano /etc/nginx/conf.d/YOUR_QUOKKA_DOMAIN.conf
server {
        server_name YOUR_QUOKKA_DOMAIN;
	client_body_in_file_only clean;
	client_body_buffer_size 64K;
	client_max_body_size 40M;
	sendfile on;
        send_timeout 300s;
        location ~ ^/(static|mediafiles)/ {
            root    /home/quokka/quokka-env/quokka/quokka;
            location ~* ^.+.(py|pyc|sh|bat|ini|pot|git)$ {deny all; }
            expires 7d;
        }
        location / {
            uwsgi_pass      unix:/home/quokka/quokka-env/quokka/etc/logs/quokka.socket;
            include         /etc/nginx/uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
        }
}

Install uWSGI using pip

pip install --upgrade uwsgi

Create uwsgi configuration file for Quokka:

mkdir /etc/uwsgi.d/
[root]$ nano /etc/uwsgi.d/quokka.ini
[uwsgi]
chmod-socket = 666
virtualenv = /home/quokka/quokka-env
mount  = /=wsgi:application
chdir  = /home/quokka/quokka-env/quokka
socket = /home/quokka/quokka-env/quokka/etc/logs/%n.socket
stats  = /home/quokka/quokka-env/quokka/etc/logs/%n.stats.socket
logto  = /home/quokka/quokka-env/quokka/etc/logs/%n.log
workers = 4
uid = quokka
gid = quokka
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192

Open your editor of choice and create a new systemd service for Quokka:

[root]$ nano /etc/systemd/system/uwsgi.service

and add the following code lines:

[Unit]
Description=uWSGI Emperor Service
After=syslog.target

[Service]
ExecStart=/usr/bin/uwsgi --master --die-on-term --emperor /etc/uwsgi.d
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

Start and enable uWSGI at boot:

[root]$ systemctl enable uwsgi
[root]$ systemctl start uwsgi

Start and enable Nginx at boot:

[root]$ systemctl enable nginx
[root]$ systemctl start nginx

That’s it. You have successfully installed your Quokka. To access it, open http://YOUR_QUOKKA_DOMAIN/ in your browser. For more information about Quokka, please refer to the official Quokka website.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment