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.


Get source code

The Nitrate source code is available at:

You can get the latest changes with git easily:

git clone
git checkout --track [a proper tag or branch]

Install dependencies

Install devel packages that should be installed first:

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

Install dependencies:

sudo pip install path/to/Nitrate

Install from source code

After downloading the source code, go to the source code directory and install this project with python

cd [nitrate_download_path]/nitrate
sudo python install

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/

    '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: migrate --settings=tcms.settings.product

Create super user if needed: createsuperuser --settings=tcms.settings.product

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 as the default settings. After backed up the, please modify settings based on your custom configurations in settings/ For more information see Nitrate configuration settings!

Use cache (Optional)

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

Refer to following docs for more details:

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: 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.

Install Apache & mod_wsgi

Install httpd & mod_wsgi:

sudo yum install httpd mod_wsgi

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

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/

Run following command to collect static files:

sudo collectstatic --settings=tcms.settings.product


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/

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:

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

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

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

# Configurations for mod_wsgi
WSGIScriptAlias / /usr/lib/python2.6/site-packages/tcms/
WSGIPythonPath /usr/lib/python2.6/site-packages
WSGIPassAuthorization On

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

    Options All
    AllowOverride 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."

<Location "/static">
    SetHandler None

    # 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:

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: