5. Installing nitrate on RHEL6 with Apache and MySQL

This deployment document presumes that you are running Red Hat Enterprise Linux 6. Of course, all deployment steps being described through this document also apply to other Linux distributions, such as CentOS, openSUSE, or Debian.

This document aims to deployment within a server that will serve test case management service to stuffs or customers. Therefore, all commands and configuration are done with system Python interpreter and those configuration files installed in the standard system directories, like the /etc/httpd/conf/httpd.conf.

5.1. Installation

5.1.1. Get source code

The Nitrate source code is available at:https://github.com/Nitrate/Nitrate

You can get the latest changes with git easily:

git clone https://github.com/Nitrate/Nitrate.git
git checkout --track [a proper tag or branch]

5.1.2. Install dependencies

Install devel packages that should be installed first:

sudo yum install gcc w3m python-devel mysql-devel krb5-devel libxml2-devel libxslt-devel

Install dependencies from requirements/mysql.txt:

sudo pip install -r requirements/mysql.txt


Alternatively you can use requirements/postgres.txt for PostgreSQL!

5.1.3. Install from source code

After downloading the source code, go to the source code directory and install this project with python setup.py:

cd [nitrate_download_path]/nitrate
sudo python setup.py install

5.2. Initialize database

Database is required by Nitrate (and all of Django apps). Django ORM supports many database backends, we recommend you to use MySQL.

Create database and user for nitrate in mysql:

mysql> create database nitrate;
mysql> GRANT all privileges on nitrate.* to nitrate@'%' identified by 'password';

Update settings/product.py:

    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'nitrate',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'nitrate',
        'PASSWORD': 'password',
        'HOST': '',                      # Empty for localhost through domain sockets or '' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.

Create tables and load initial data:

django-admin.py migrate --settings=tcms.settings.product

Create super user if needed:

django-admin.py createsuperuser --settings=tcms.settings.product

5.3. Config Settings

First please go to nitrate root path, it’s different based on your current OS.

Like on RHEL6.3, the root path is located in:


As we plan to deploy an example server for nitrate, we can use product.py as the default settings. After backed up the product.py, please modify settings based on your custom configurations in settings/product.py. For more information see Nitrate configuration settings!

5.4. Use cache (Optional)

You can use Django’s cache framework to get better performance.

Refer to following docs for more details:

5.5. Start the django app

After upon steps is completed, now you can try to start the web server which is a built-in development server provided by Django to test if the app can run as expected. Run following command:

django-admin.py runserver --settings=tcms.settings.product

Then try to use web browser to open http://localhost:8000/ to verify the working status of this web service.

5.6. Install Apache & mod_wsgi

Install httpd & mod_wsgi:

sudo yum install httpd mod_wsgi

5.6.1. Create upload dir

Create upload dir and change dir own & group to apache:

sudo mkdir -p /var/nitrate/uploads
sudo chown apache:apache /var/nitrate/uploads

5.6.2. Collect static files

The default directory to store static files is /var/nitrate/static, you can modify it by changing STATIC_ROOT setting in /path/to/nitrate/tcms/settings/product.py.

Run following command to collect static files:

sudo django-admin.py collectstatic --settings=tcms.settings.product

Reference: https://docs.djangoproject.com/en/1.5/howto/static-files/deployment/

5.6.3. Deploy with Apache

Deploying Django projects with Apache and mod_wsgi is the recommended way to get them into production.

Create wsgi.conf in /etc/httpd/conf.d/ which include one line:

LoadModule wsgi_module modules/mod_wsgi.so

To build a production server with Apache, just copy apache conf to /etc/httpd/conf.d/.

I presume that the conf file is named nitrate-httpd.conf.

# Deployment using mod_wsgi
# Useful documentation:
# https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/

# Force the use of ssl:
#<IfModule mod_rewrite.c>
#    RewriteEngine on
#    RewriteCond %{HTTPS} off
#    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

# Limit threads forked:
# prefork MPM 
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
MaxRequestsPerChild 0

# Configurations for mod_wsgi
WSGIDaemonProcess nitrateapp python-path=/venv/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages
WSGIProcessGroup nitrateapp
WSGIScriptAlias / /usr/lib/python2.7/site-packages/tcms/wsgi.py
WSGIPassAuthorization On

<Location "/">
    # ====================
    # Handler for mod_wsgi
    # ====================
    SetHandler wsgi-script

    Options All
    Require all granted
    LimitRequestBody 10485760
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript application/x-javascript text/css

    ErrorDocument 401 "Your request is unauthorization."

# Make sure static files are collected to this dir
Alias /static /usr/share/nitrate/static

<Location "/static">
    SetHandler None
    Options -Indexes

    # Disable auth on the static content, so that we're aren't forced to
    # use Kerberos.  Doing so would remove "Expires" headers from the static
    # content, which would lead to poor page-load times.
    AuthType none
    Satisfy Any
    Allow from All

    # Many file types are likely to benefit from compression
    # Enable gzip compression on them:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript application/x-javascript text/css

    # Set far-future Expires headers on static content
    # (trac 184):
    ExpiresActive On
    ExpiresDefault "access plus 10 years"

Change any configuration to fit your deployment environment.

In /etc/httpd/conf/httpd.conf, set the following settings simply:

ServerName example.com:80
Listen ip_address:80

After configuration, run:

sudo service httpd start

Please go to browser to have a verify if this service runs successfully.

If any problem, please refer to log file:


Or any access info, refer to: